Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registration of backend tensorflow failed #739

Closed
ghost opened this issue Sep 27, 2018 · 33 comments
Closed

Registration of backend tensorflow failed #739

ghost opened this issue Sep 27, 2018 · 33 comments
Assignees

Comments

@ghost
Copy link

ghost commented Sep 27, 2018

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.

@nkreeger
Copy link
Contributor

tfjs-node now ships with tfjs - so you don't need to npm install @tensorflow/tfjs. Can you show me the output from the command:

npm install @tensorflow/tfjs-node-gpu

Make sure you have Python 2.7 on windows - 3.x is not supported with node-gyp (build tool for Node.js addons).

@ghost
Copy link
Author

ghost commented Sep 28, 2018

$ npm i @tensorflow/tfjs-node-gpu

> @tensorflow/[email protected] install C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu
> node scripts/install.js gpu download

* Downloading libtensorflow

* Building TensorFlow Node.js bindings

> [email protected] postinstall C:\Users\me\Repos\predict\node_modules\protobufjs
> node scripts/postinstall

npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

+ @tensorflow/[email protected]
added 48 packages from 49 contributors and audited 66 packages in 18.295s
found 0 vulnerabilities

If npm install @tensorflow/tfjs is no longer necessary, what is the correct require/import usage? Is it still the following?

const tf = require('@tensorflow/tfjs')

require('@tensorflow/tfjs-node-gpu')

@craftgear
Copy link

Hi, I have the same problem with a different error message.

Registration of backend tensorflow failed
TypeError: backend.setDataMover is not a function

Once I remove node_modules/@tensorflow and install @tensorflwo/tfjs-node only then the error disappears.

I guess the reason I got above error was I first installed tfjs then add tfjs-node afterwords.
Maybe dependency versions unmet?

Anyway, thanks @nkreeger 👍

@brannondorsey
Copy link
Contributor

I experienced a similar problem to @craftgear. I already had @tensorflow/tfjs as a dependency in a project and added @tensorflow/tfjs-node. This caused the registration of the tensorflow backend to fail. Removing the node_modules/ folder and reinstalling with npm install fixed the problem. Strangely, the project now works even with both dependencies:

  "dependencies": {
    "@tensorflow/tfjs": "^0.12.7",
    "@tensorflow/tfjs-node": "^0.1.17",
    "electron": "^2.0.8"
  }

@nkreeger
Copy link
Contributor

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');

...

@brannondorsey
Copy link
Contributor

@nkreeger thanks for that info. So it can be assumed that @tensorflow/tfjs will ship with @tensorflow/tfjs-node indefinitely (or if it is removed a breaking semver increment will be used) and projects using @tensorflow/tfjs-node should remove dependence on @tensorflow/tfjs explicitly, correct?

@ghost
Copy link
Author

ghost commented Sep 29, 2018

What about the GPU version? I'm still having the issue in my original post after a fresh install of only @tensorflow/tfjs-node-gpu.

Console output:

$ npm i @tensorflow/tfjs-node-gpu

> @tensorflow/[email protected] install C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu
> node scripts/install.js gpu download

* Downloading libtensorflow

* Building TensorFlow Node.js bindings

> [email protected] postinstall C:\Users\me\Repos\predict\node_modules\protobufjs
> node scripts/postinstall

npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

+ @tensorflow/[email protected]
added 48 packages from 49 contributors and audited 66 packages in 21.319s
found 0 vulnerabilities



$ npm start

> [email protected] start C:\Users\me\Repos\predict
> node index.js

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-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)

============================
Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
============================

@nkreeger
Copy link
Contributor

@timbur Can you try this:

cd node_modules/@tensorflow/tfjs-node-gpu
node-gyp build

Post the output here.

Also - might be easier to clone the tfjs-node repo and try running node-gyp build inside of that clone.

@ghost
Copy link
Author

ghost commented Sep 29, 2018

Output:

me@WINDOWS MINGW64 ~/Repos/predict
$ cd node_modules/@tensorflow/tfjs-node-gpu

me@WINDOWS MINGW64 ~/Repos/predict/node_modules/@tensorflow/tfjs-node-gpu
$ node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  tfjs_binding.vcxproj -> C:\Users\me\Repos\predict\node_modules\@tensorflow\tfjs-node-gpu\build\Release\\tfjs_binding.node
gyp info ok

me@WINDOWS MINGW64 ~/Repos/predict/node_modules/@tensorflow/tfjs-node-gpu
$ cd ../../..

me@WINDOWS MINGW64 ~/Repos/predict
$ npm start

> [email protected] start C:\Users\me\Repos\predict
> node index.js

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-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)

============================
Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
============================

Also, the file is definitely there:

me@WINDOWS MINGW64 ~/Repos/predict
$ ls C:/Users/me/Repos/predict/node_modules/@tensorflow/tfjs-node-gpu/build/Release/tfjs_binding.node
'C:/Users/me/Repos/predict/node_modules/@tensorflow/tfjs-node-gpu/build/Release/tfjs_binding.node'*

I wonder if I should try a fresh install of everything - i.e., node, npm, python, git bash, etc. I wonder if somehow things got borked because I did at one point have both python 2 and 3 installed (now only 2).

@DavidGOrtega
Copy link

DavidGOrtega commented Oct 4, 2018

@nkreeger
I have done what you said just only installing

"dependencies": {
    "@tensorflow/tfjs-node": "^0.1.17"
  },

then index.js with just

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

runned as .mjs

Error: Cannot find module @tensorflow/tfjs
    at search (internal/modules/esm/default_resolve.js:28:12)

runned with webpack

> [email protected] build C:\nodetfjs
> webpack --progress -d

Hash: 11790bf0fd619b698fb5
Version: webpack 4.20.2
Time: 2350ms
Built at: 10/04/2018 12:44:54 PM
         Asset      Size  Chunks             Chunk Names
main.bundle.js  1.13 MiB    main  [emitted]  main
Entrypoint main = main.bundle.js
[./index.js] 48 bytes {main} [built]
[./node_modules/bindings sync recursive] ./node_modules/bindings sync 160 bytes {main} [optional] [built]
[crypto] external "crypto" 42 bytes {main} [optional] [built]
[fs] external "fs" 42 bytes {main} [built]
[path] external "path" 42 bytes {main} [built]
[util] external "util" 42 bytes {main} [built]
    + 10 hidden modules

WARNING in ./node_modules/bindings/bindings.js 81:22-40
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./index.js

WARNING in ./node_modules/bindings/bindings.js 81:43-53
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@tensorflow/tfjs-node/dist/index.js
 @ ./index.js

C:\nodetfjs>node ./dist/main.bundle.js
Registration of backend tensorflow failed
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at assertPath (path.js:39:11)
    at dirname (path.js:653:5)
    at Function.getRoot (webpack-internal:///./node_modules/bindings/bindings.js:151:13)
    at bindings (webpack-internal:///./node_modules/bindings/bindings.js:60:32)
    at eval (webpack-internal:///./node_modules/@tensorflow/tfjs-node/dist/index.js:10:60)
    at e.registerBackend (webpack-internal:///./node_modules/@tensorflow/tfjs-node/node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js:234:48552)
    at eval (webpack-internal:///./node_modules/@tensorflow/tfjs-node/dist/index.js:9:9)
    at Object../node_modules/@tensorflow/tfjs-node/dist/index.js (C:\nodetfjs\dist\main.bundle.js:109:1)
    at __webpack_require__ (C:\nodetfjs\dist\main.bundle.js:20:30)
    at eval (webpack-internal:///./index.js:3:1)

After installing @tensorflow/tfjs

C:\nodetfjs>node --experimental-modules index.mjs
(node:26444) ExperimentalWarning: The ESM module loader is experimental.
cpu backend was already registered. Reusing existing backend
2018-10-04 13:08:55.931285: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
Registration of backend tensorflow failed
TypeError: backend.setDataMover is not a function
    at Environment.registerBackend (C:\\nodetfjs\node_modules\@tensorflow\tfjs-core\dist\environment.js:186:21)
    at Object.<anonymous> (C:\\nodetfjs\node_modules\@tensorflow\tfjs-node\dist\index.js:9:9)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    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 createDynamicModule (internal/modules/esm/translators.js:54:15)
    at setExecutor (internal/modules/esm/create_dynamic_module.js:50:23)
    at file:///C://nodetfjs/node_modules/@tensorflow/tfjs-node/dist/index.js:11:5

I did not have the kind of luck @brannondorsey had. No matter if I install them one by one or cleaning aup everything running install with the dependencies

@nkreeger
Copy link
Contributor

nkreeger commented Oct 4, 2018

It looks like it is having trouble installing MSVS - according to the node-gyp docs, you can do either:

1). npm install --global --production windows-build-tools
2.) Install build tools manually - links on their README

@rthadur
Copy link
Contributor

rthadur commented Nov 7, 2018

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

@rthadur rthadur closed this as completed Nov 7, 2018
@xiaodeaux
Copy link

xiaodeaux commented Nov 8, 2018

PS C:\Users\xdx\Documents\programming\programming-env-debug> cd node_modules/@tensorflow/tfjs-node-gpu
PS C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu> node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.11.0 | win32 | x64
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  deps-stage
  (node:7796) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename 'C:\Users\xdx\Documents\programming\programming-en
  v-debug\node_modules\@tensorflow\tfjs-node-gpu\deps\lib\tensorflow.dll' -> 'C:\Users\xdx\Documents\programming\programming-env-debug\node_modules
  \@tensorflow\tfjs-node-gpu\build\Release\tensorflow.dll'
  (node:7796) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function wi
  thout a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:7796) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will
   terminate the Node.js process with a non-zero exit code.
  generate_def
  build-tensorflow-lib
  Microsoft (R) Library Manager Version 14.00.24210.0
  Copyright (C) Microsoft Corporation.  All rights reserved.

     Creating library Release\obj\tfjs_binding\tensorflow.lib and object Release\obj\tfjs_binding\tensorflow.exp
     Creating library C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.li
  b and object C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.exp
  Generating code
  2 of 842 functions ( 0.2%) were compiled, the rest were copied from previous compilation.
    0 functions were new in current compilation
    0 functions had inline decision re-evaluated but remain unchanged
  Finished generating code
  tfjs_binding.vcxproj -> C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\\tfjs_bindi
  ng.node
  tfjs_binding.vcxproj -> C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_bindin
  g.pdb (Full PDB)
gyp info ok
PS C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu> cd ../../../
PS C:\Users\xdx\Documents\programming\programming-env-debug> ts-node .\src\tfjs-test.tsx
Registration of backend tensorflow failed
Error: The specified module could not be found.
\\?\C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at bindings (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\bindings\bindings.js:81:44)
    at C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:11:60
    at Environment.registerBackend (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-core\src\environment.ts:417:23)
    at Object.<anonymous> (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:10:9)

============================
Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlo
w C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.
============================

I did node-gyp build and... it kinda succeeded? I'm not really sure how to interpret the errors or unhandled promise rejections. @nkreeger

@nkreeger
Copy link
Contributor

nkreeger commented Nov 8, 2018

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

@xiaodeaux
Copy link

PS C:\Users\xdx\Documents\programming\programming-env-debug> node .\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js
* Downloading libtensorflow
[==============================] 5070185/bps 99% 0.0s
* Building TensorFlow Node.js bindings
C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:154
      throw new Error('node-gyp rebuild failed with: ' + err);
      ^

Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@10.11.0 | win32 | x64
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ 'C:\\Users\\xdx\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\xdx\\Documents\\programming\\programming-env-debug\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\xdx\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\xdx\\.node-gyp\\10.11.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\xdx\\.node-gyp\\10.11.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\xdx\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\xdx\\.node-gyp\\10.11.0\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\xdx\\Documents\\programming\\programming-env-debug',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\Users\\xdx\\Documents\\programming\\programming-env-debug\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp: binding.gyp not found (cwd: C:\Users\xdx\Documents\programming\programming-env-debug) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\xdx\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xdx\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\xdx\Documents\programming\programming-env-debug
gyp ERR! node -v v10.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

    at cp.exec (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:154:13)
    at ChildProcess.exithandler (child_process.js:296:5)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)

@nkreeger I got this output. 😟

@nkreeger
Copy link
Contributor

nkreeger commented Nov 8, 2018

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

@xiaodeaux
Copy link

PS C:\Users\xdx\Documents\programming\programming-env-debug> yarn install
yarn install v1.12.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 265.89s.
PS C:\Users\xdx\Documents\programming\programming-env-debug> ts-node .\src\tfjs-test.tsx
Registration of backend tensorflow failed
Error: The specified module could not be found.
\\?\C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at bindings (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\bindings\bindings.js:81:44)
    at C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:11:60
    at Environment.registerBackend (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-core\src\environment.ts:417:23)
    at Object.<anonymous> (C:\Users\xdx\Documents\programming\programming-env-debug\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:10:9)

@nkreeger I'm still getting that same error. It looks like it is also using a globally installed node-gyp package? Do you think that's a problem, and should I remove it from the global package?

Thank you very much for your help. 🤗

@rahbari
Copy link

rahbari commented Nov 17, 2018

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

@nkreeger
Copy link
Contributor

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.

@xiaodeaux
Copy link

@rahbari Thanks for your edit pointing out that the software libraries need to be installed as prerequisites. I guess I just glanced over that or ignored it. I'm doing that now and I'm confident that will solve the issue I'm having. I should have read the documentation more closely. ❤👀

@rahbari
Copy link

rahbari commented Dec 6, 2018

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

@happy-machine
Copy link

Hi i'm getting the same error here in 2019! Would appreciate some help, about to go into production

Thanks!

Dan

To get help from the community, check out our Google group.

TensorFlow.js version

TFJS core: "version": "0.13.11"
TFJS layers: "version": "0.8.5"
TFJS node: "version": "0.1.21"

Browser version

non applicable - API

Describe the problem or feature request

Hi

I've just installed a new aws ec2 instance of an api that serves predictions from a node API, node version is 8.13 which has worked for me previously on the same instance, but after pulling a newer version of the codebase i am now getting this error:

Registration of backend tensorflow failed
Error: libtensorflow.so: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (module.js:682:18)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at bindings (/home/ubuntu/xAI-API/node_modules/bindings/bindings.js:84:48)
at /home/ubuntu/xAI-API/node_modules/@tensorflow/tfjs-node/dist/index.js:11:60
at Environment.registerBackend (/home/ubuntu/xAI-API/node_modules/@tensorflow/tfjs-core/dist/environment.js:210:27)
at Object. (/home/ubuntu/xAI-API/node_modules/@tensorflow/tfjs-node/dist/index.js:10:9)

Code to reproduce the bug / link to feature request

as above

@dsmilkov
Copy link
Contributor

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/.

@happy-machine
Copy link

Hey .. that nailed it thanks, reinstalled tfjs-node, all working fine now : )

@qcgm1978
Copy link

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/.

Yes. I removed node_modules folder and reinstall modules including @tensorflow/tfjs-node that works.

@ghost
Copy link
Author

ghost commented Jan 31, 2019

Can someone please explain step by step how to get the gpu version to install on a fresh windows 10? I have everything else installed properly afaik and it still craps out at the node-gyp rebuild step of install.js with no information whatsoever on what the problem is. The plain node version installs fine. It’s been 4 months.

@ghost
Copy link
Author

ghost commented Jan 31, 2019

Yeah I officially give up. I can’t believe how bad this node-gyp stuff still is in 2019. Is it easier to use the gpu version on Linux or something?

Also, why is the rebuild step even required? Why doesn't it come with whatever is needed, precompiled?

This is the error I see no matter what:

$ rm -rf node_modules/ && npm install @tensorflow/tfjs-node-gpu

> @tensorflow/[email protected] install E:\Repos\wowww\node_modules\@tensorflow\tfjs-node-gpu
> node scripts/install.js gpu download

* Downloading libtensorflow

* Building TensorFlow Node.js bindings
E:\Repos\wowww\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:171
      throw new Error('node-gyp rebuild failed with: ' + err);
      ^

Error: node-gyp rebuild failed with: Error: Command failed: node-gyp rebuild
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Repos\wowww\node_modules\@tensorflow\tfjs-node-gpu
gyp ERR! node -v v11.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

    at cp.exec (E:\Repos\wowww\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:171:13)
    at ChildProcess.exithandler (child_process.js:304:5)
    at ChildProcess.emit (events.js:197:13)
    at maybeClose (internal/child_process.js:978:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)

@kir486680
Copy link

I am facing the same issue. I am using react native and It works fine when i import it import * as tf from '@tensorflow/tfjs'; It works fine when i create a model but when i do const xs = tf.tensor2d([[1], [2], [3], [4], [5], [6], [7]], [7, 1]); I get Error: Could not initialize any backends, all backend initializations failed . I tried to reinstall tfjs by removing node_modules folder several times and it still doesn't help. (installing tfjs doesn't geive me any errors)

Version used: "@tensorflow/tfjs": "^1.1.2"

Capture

@nkreeger
Copy link
Contributor

@kir486680 We don't officially support React Native - it is something we're planning on investigating soon.

@julkar9
Copy link

julkar9 commented Jun 5, 2019

@nkreeger , what is the isuue here please.

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/var/www/html/smartnexuscarewithnodejs/node_modules/@tensorflow/tfjs-node-gpu/build'
ACTION binding_gyp_tfjs_binding_target_deps_stage Release/libtensorflow.so
(node:14038) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, rename '/var/www/html/smartnexuscarewithnodejs/node_modules/@tensorflow/tfjs-node-gpu/deps/lib/libtensorflow.so' -> '/var/www/html/smartnexuscarewithnodejs/node_modules/@tensorflow/tfjs-node-gpu/build/Release/libtensorflow.so'
(node:14038) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14038) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
make: Leaving directory '/var/www/html/smartnexuscarewithnodejs/node_modules/@tensorflow/tfjs-node-gpu/build'
gyp info ok

@julkar9
Copy link

julkar9 commented Jun 5, 2019

Initialization of backend tensorflow failed
Error: libcublas.so.10.0: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (internal/modules/cjs/loader.js:805:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at bindings (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/bindings/bindings.js:84:48)
at Object.factory (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node-gpu/dist/index.js:48:60)
at Engine.initializeBackend (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:237:48)
at Engine. (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:200:35)
Initialization of backend tensorflow failed
Error: libcublas.so.10.0: cannot open shared object file: No such file or directory
at Object.Module._extensions..node (internal/modules/cjs/loader.js:805:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at bindings (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/bindings/bindings.js:84:48)
at Object.factory (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-node-gpu/dist/index.js:48:60)
at Engine.initializeBackend (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:237:48)
at Engine.initializeBackendsAndReturnBest (/home/julkarnine/Downloads/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:291:27)

============================
Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.

@julkar9
Copy link

julkar9 commented Jun 5, 2019

tried to build with bazel: got bellow error

tensorflow git:(master) bazel build --config=monolithic //tensorflow/tools/lib_package:libtensorflow

Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=91
INFO: Reading rc options for 'build' from /home/julkarnine/Downloads/tensorflow/.bazelrc:
'build' options: --apple_platform_type=macos --define framework_shared_object=true --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone --strategy=Genrule=standalone -c opt --announce_rc --define=grpc_no_ares=true --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include
INFO: Reading rc options for 'build' from /home/julkarnine/Downloads/tensorflow/.tf_configure.bazelrc:
'build' options: --action_env PYTHON_BIN_PATH=/usr/bin/python --action_env PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages --python_path=/usr/bin/python --config=xla --action_env TF_CONFIGURE_IOS=0
INFO: Found applicable config definition build:xla in file /home/julkarnine/Downloads/tensorflow/.tf_configure.bazelrc: --define with_xla_support=true
INFO: Found applicable config definition build:monolithic in file /home/julkarnine/Downloads/tensorflow/.bazelrc: --define framework_shared_object=false
Traceback (most recent call last):
File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
from builtins import bytes # pylint: disable=redefined-builtin
ImportError: No module named builtins
INFO: Call stack for the definition of repository 'local_config_git' which is a git_configure (rule definition at /home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl:63:17):

  • /home/julkarnine/Downloads/tensorflow/tensorflow/workspace.bzl:66:5
  • /home/julkarnine/Downloads/tensorflow/WORKSPACE:94:1
    ERROR: An error occurred during the fetch of repository 'local_config_git':
    Traceback (most recent call last):
    File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 61
    _fail(result.stderr)
    File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 14, in _fail
    fail(("%sGit Configuration Error:%s %...)))
    Git Configuration Error: Traceback (most recent call last):
    File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
    from builtins import bytes # pylint: disable=redefined-builtin
    ImportError: No module named builtins

INFO: Call stack for the definition of repository 'grpc' which is a tf_http_archive (rule definition at /home/julkarnine/Downloads/tensorflow/third_party/repo.bzl:126:19):

  • /home/julkarnine/Downloads/tensorflow/tensorflow/workspace.bzl:487:5
  • /home/julkarnine/Downloads/tensorflow/WORKSPACE:94:1
    INFO: Call stack for the definition of repository 'llvm' which is a tf_http_archive (rule definition at /home/julkarnine/Downloads/tensorflow/third_party/repo.bzl:126:19):
  • /home/julkarnine/Downloads/tensorflow/tensorflow/workspace.bzl:522:5
  • /home/julkarnine/Downloads/tensorflow/WORKSPACE:94:1
    INFO: Call stack for the definition of repository 'jpeg' which is a third_party_http_archive (rule definition at /home/julkarnine/Downloads/tensorflow/third_party/repo.bzl:206:28):
  • /home/julkarnine/Downloads/tensorflow/third_party/jpeg/workspace.bzl:6:5
  • /home/julkarnine/Downloads/tensorflow/tensorflow/workspace.bzl:45:5
  • /home/julkarnine/Downloads/tensorflow/tensorflow/workspace.bzl:73:5
  • /home/julkarnine/Downloads/tensorflow/WORKSPACE:94:1
    ERROR: /home/julkarnine/Downloads/tensorflow/tensorflow/core/BUILD:2779:1: no such package '@local_config_git//': Traceback (most recent call last):
    File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 61
    _fail(result.stderr)
    File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 14, in _fail
    fail(("%sGit Configuration Error:%s %...)))
    Git Configuration Error: Traceback (most recent call last):
    File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
    from builtins import bytes # pylint: disable=redefined-builtin
    ImportError: No module named builtins

and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/julkarnine/Downloads/tensorflow/tensorflow/core/BUILD:2779:1: no such package '@local_config_git//': Traceback (most recent call last):
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 61
_fail(result.stderr)
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 14, in _fail
fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
from builtins import bytes # pylint: disable=redefined-builtin
ImportError: No module named builtins

and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/julkarnine/Downloads/tensorflow/tensorflow/core/BUILD:2779:1: no such package '@local_config_git//': Traceback (most recent call last):
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 61
_fail(result.stderr)
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 14, in _fail
fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
from builtins import bytes # pylint: disable=redefined-builtin
ImportError: No module named builtins

and referenced by '//tensorflow/core:version_info_gen'
ERROR: Analysis of target '//tensorflow/tools/lib_package:libtensorflow' failed; build aborted: no such package '@local_config_git//': Traceback (most recent call last):
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 61
_fail(result.stderr)
File "/home/julkarnine/Downloads/tensorflow/third_party/git/git_configure.bzl", line 14, in _fail
fail(("%sGit Configuration Error:%s %...)))
Git Configuration Error: Traceback (most recent call last):
File "/home/julkarnine/.cache/bazel/_bazel_julkarnine/f992fcea7a4b849a4642acfba88e61fc/external/org_tensorflow/tensorflow/tools/git/gen_git_source.py", line 29, in
from builtins import bytes # pylint: disable=redefined-builtin
ImportError: No module named builtins

INFO: Elapsed time: 5.385s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (115 packages loaded, 4937 targets configured
)
Fetching @gif_archive; Restarting.

@julkar9
Copy link

julkar9 commented Jun 5, 2019

is there any problem
./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce RTX 2060"
CUDA Driver Version / Runtime Version 10.0 / 9.0
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 5903 MBytes (6190006272 bytes)
MapSMtoCores for SM 7.5 is undefined. Default to use 64 Cores/SM
MapSMtoCores for SM 7.5 is undefined. Default to use 64 Cores/SM
(30) Multiprocessors, ( 64) CUDA Cores/MP: 1920 CUDA Cores
GPU Max Clock rate: 1710 MHz (1.71 GHz)
Memory Clock rate: 7001 Mhz
Memory Bus Width: 192-bit
L2 Cache Size: 3145728 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 3 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.0, CUDA Runtime Version = 9.0, NumDevs = 1
Result = PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests