tfjs: Registration of backend tensorflow failed

TensorFlow.js version

    "@tensorflow/tfjs": "^0.13.1",
    "@tensorflow/tfjs-node-gpu": "^0.1.17",

Browser version

N/A

Describe the problem or feature request

Following error is displayed:

Registration of backend tensorflow failed
Error: The specified module could not be found.
\\?\C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:731:18)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at bindings (C:\Users\me\Repos\predict\node_modules\bindings\bindings.js:81:44)
    at C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:10:60
    at Environment.registerBackend (C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu\node_modules\@tensorflow\tfjs-core\dist\environment.js:196:27)
    at Object.<anonymous> (C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:9:9)

I’ve checked the specified directory/file and it exists.

Code to reproduce the bug / link to feature request

I’m trying the most basic example shown here: https://js.tensorflow.org/#getting-started

I have tfjs-node-gpu successfully installed on Windows. Tried both:

const tfGPU = require('@tensorflow/tfjs-node-gpu')
const tf = require('@tensorflow/tfjs')

And:

const tf = require('@tensorflow/tfjs')
const tfGPU = require('@tensorflow/tfjs-node-gpu')

@tensorflow/tfjs-node-gpu is required only once.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 33 (12 by maintainers)

Most upvoted comments

I have the same problem as @timbur, tfjs_binding.node is there but I got “Error: The specified module could not be found.”

annotation 2018-11-17 163615

I tied both CommonJS and ES6Modules:

const tf = require('@tensorflow/tfjs')
require('@tensorflow/tfjs-node-gpu')

and:

import * as tf from '@tensorflow/tfjs';
import '@tensorflow/tfjs-node-gpu';

annotation 2018-11-17 163852

annotation 2018-11-17 163959

I have Win10, Nodejs 11.2, Python 2.7. I tried VS2015 and VS2017, with both I get same error after install.

EDIT ------------------------------------------

after some struggles I found I out that I haven’t install required nvidia drivers and tools, so for those who have the same problem you must install CUDA Toolkit 9 (Not 10 for now) and cuDNN SDK for CUDA Toolkit 9 and append them to windows path which is explained in detail at this page: https://www.tensorflow.org/install/gpu

We ship 0.12.7 right now in the tfjs-node package. Sorry for the confusion - but you only have to npm install @tensorflow/tfjs-node today. That package ships with a supported version of @tensorflow/tfjs.

So basically this:

  "dependencies": {
    "@tensorflow/tfjs-node": "^0.1.17",
    ...
  }
// Package ships with '@tensorflow/tfjs':
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');

...

cc @nkreeger . Have you tried removing node_modules, and re-running yarn/npm to re-install the tfjs-node dependency? Looks like the TF C++ library is missing in node_modules/.

@nkreeger I hadn’t installed CUDA SDK, after installing everything works fine in Intellij.

It looks like you are running inside JetBrains? If so - can you try running through that command prompt that you installed with? I wonder if a path is not working correctly in the JetBrains IDE.

When you invoke through node_modules - node_gyp tries to compile in your actual project directory. Might be easier to rm -rf node_modules and re-run yarn or npm install

node-gyp build won’t really work because we do some pre-work. You’ll want to invoke: https://github.com/tensorflow/tfjs-node/blob/master/scripts/install.js