tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Issue running tfjs-node-gpu under Windows

Open eggerand13 opened this issue 7 years ago • 34 comments

TensorFlow.js version

tfjs-node-gpu 1.2.7

Node version

v12.9.0

Describe the problem or feature request

When trying to run a file that only contains the following line: const tf = require('@tensorflow/tfjs-node-gpu');

I will receive the following error:

internal/modules/cjs/loader.js:977
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\C:\development\JS ML\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:977:18)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (C:\Entwicklung_neu\JS ML\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:44:16)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)

I tried to find out why there is this strange "\?" prepended to the path but I couldn't really find out why it is happening. The code will run without any problem when I only use the CPU module (tfjs-node).

I have a CUDA compatible graphics card (GTX960M) and followed the complete installation guide. When installing the module I have only Python 2.7 installed. The installation of the module also seems to work as expected:

> @tensorflow/[email protected] install C:\development\JS ML\node_modules\@tensorflow\tfjs-node-gpu
> node scripts/install.js gpu download

GPU-windows-1.2.7.zip
* Downloading libtensorflow
[==============================] 3508656/bps 100% 0.0s
[==============================] 1862362/bps 100% 0.0s
* Building TensorFlow Node.js bindings
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

added 86 packages from 83 contributors and audited 150 packages in 98.859s
found 0 vulnerabilities

I would be very glad if anyone could help me with this issue.

eggerand13 avatar Aug 25 '19 11:08 eggerand13

The same issue in windows 10. Error: Cannot find module 'C:\Users\zx\work\escher-project\escher-util\node_modules\_@[email protected]@@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object.<anonymous> (C:\Users\zx\work\escher-project\escher-util\node_modules\_@[email protected]@@tensorflow\tfjs-node\dist\index.js:44:16) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) 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)

chenqing avatar Aug 25 '19 14:08 chenqing

@eggerand13 @chenqing I just updated the addon module for windows. Please try @tensorflow/tfjs-node @ 1.2.8.

kangyizhang avatar Aug 25 '19 18:08 kangyizhang

@eggerand13 @chenqing I just updated the addon module for windows. Please try @tensorflow/tfjs-node @ 1.2.8.

Thank you very much for your help. Could you point me in the right direction HOW I could get the version 1.2.8? NPM doesn't know about ("No matching version found for @tensorflow/tfjs-node-gpu@^1.2.8") and I also see that the latest commit in tfjs-node is already 17 hours old and it's not about this issue. Also in your private fork of tfjs-node I don't see any updates.

I hope am not missing something obvious here.

Thank you.

eggerand13 avatar Aug 25 '19 18:08 eggerand13

I had this same error. I further went to bulid @tensorflow/tfjs-node-gyp using node-gyp configure

M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu>node-gyp configure
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 2.7.11 found at "c:\tools\Python27\python.exe"
gyp info find VS using VS2015 (14.0) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio 14.0"
gyp info find VS run with --verbose for detailed information
gyp info spawn c:\tools\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\tools\\nodejs\\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   '-I',
gyp info spawn args   'M:\\javascript\\tensorflow\\node_modules\\@tensorflow\\tfjs-node-gpu\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\tools\\nodejs\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\d3x0r\\AppData\\Local\\node-gyp\\Cache\\12.9.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\\d3x0r\\AppData\\Local\\node-gyp\\Cache\\12.9.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\tools\\nodejs\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\d3x0r\\AppData\\Local\\node-gyp\\Cache\\12.9.0\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=M:\\javascript\\tensorflow\\node_modules\\@tensorflow\\tfjs-node-gpu',
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   'M:\\javascript\\tensorflow\\node_modules\\@tensorflow\\tfjs-node-gpu\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: Undefined variable module_name in binding.gyp 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:\tools\nodejs\node_modules\node-gyp\lib\configure.js:344:16)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\tools\\nodejs\\node.exe" "C:\\tools\\nodejs\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu
gyp ERR! node -v v12.9.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok

which I gues scomes form this part of binding.gyp

  , {
      "target_name": "action_after_build",
      "type": "none",
      "dependencies": [ "<(module_name)" ],
      "copies": [
        {
          "files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
          "destination": "<(module_path)"
        }
      }

which gracking down 'binding.gyp module name.....' seems to be a problem with node-pre-gyp which doesn't appear to be a thing....

I saw the other notes, and the WINDOWS _TROUBLESHOOTING.md but really none of that applies, bulding other things with node-gyp works fine but then I don't use <(module_name).

d3x0r avatar Aug 25 '19 19:08 d3x0r

@eggerand13 ah turns out we only published [email protected] but missed tfjs-node-gpu. I just published it. Please give it a try.

FYI we are hosting the pre compiled addon module in google cloud platform, so it's not a change in github.

kangyizhang avatar Aug 25 '19 23:08 kangyizhang

@d3x0r we switched to node-pre-gyp instead of node-gyp, that's why you are seeing the error. Please try tfjs-node-gpu @ 1.2.8 again.

FYI in future if you want to build the module by yourself, you can just run yarn or npm install, the install script (tfjs-node/scripts/install.js) will do all the work.

kangyizhang avatar Aug 25 '19 23:08 kangyizhang

@kangyizhang npm install iin... myproject/node_modules/@tensorflow/tfjs-node-gpu will then install everything in myproject/node_modules/@tensorflow/ again in myproject/node_modules/@tensorflow/tfjs-node-gpu/node_modules/@tensorflow/... including tfjs-node-gpu again :)

npm install in an addon is not a good idea :)

I was just doing npm update in an existing project that (almost)) worked with 1.2.4..



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

* Downloading libtensorflow


* Building TensorFlow Node.js bindings
M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:165
      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: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Panther\AppData\Roaming\npm\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.17134
gyp ERR! command "h:\\dev2\\nodejs\\node.exe" "C:\\Users\\Panther\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

    at cp.exec (M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu\scripts\install.js:165: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)
npm WARN [email protected] requires a peer of rollup@>=0.60.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @tensorflow/[email protected] install: `node scripts/install.js gpu download`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @tensorflow/[email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Panther\AppData\Roaming\npm-cache\_logs\2019-05-06T10_53_38_142Z-debug.log

This is a pretty clean system, there was a dependancy of rollup

M:\javascript\tensorflow>npm install @tensorflow/tfjs-node-gpu
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit
(node:11204) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added to [TLSSocket]. Use emitter.setMaxListeners() to increase limit

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

GPU-windows-1.2.8.zip
* Downloading libtensorflow
[==============================] 2506038/bps 100% 0.0s
[==============================] 658990/bps 100% 0.0s
* Building TensorFlow Node.js bindings
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v4/1.2.8/tfjs_binding-v1.2.8-node-v72-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for @tensorflow/[email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\tools\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\tools\\nodejs\\node.exe" "C:\\tools\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=M:\\javascript\\tensorflow\\node_modules\\@tensorflo
w\\tfjs-node-gpu\\lib\\napi-v4\\tfjs_binding.node" "--module_name=tfjs_binding" "--module_path=M:\\javascript\\tensorflow\\node_modules\\@tensorflow\\tfjs-node-gpu\\lib\\napi-v4" "--napi_version=4" "--node_abi_napi=napi"
 "--napi_build_version=4" "--node_napi_label=napi-v4"
gyp ERR! cwd M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu
gyp ERR! node -v v12.9.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\tools\nodejs\node.exe C:\tools\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=M:\javascript\tensorflow\node_modules\@
tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node --module_name=tfjs_binding --module_path=M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v4 --napi_version=4 --node_abi_napi=napi --napi_bui
ld_version=4 --node_napi_label=napi-v4' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (M:\javascript\tensorflow\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\\tools\\nodejs\\node.exe" "M:\\javascript\\tensorflow\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd M:\javascript\tensorflow\node_modules\@tensorflow\tfjs-node-gpu
node-pre-gyp ERR! node -v v12.9.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok

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

+ @tensorflow/[email protected]
updated 1 package and audited 150 packages in 131.814s
found 0 vulnerabilities

d3x0r avatar Aug 26 '19 05:08 d3x0r

@eggerand13 @chenqing I just updated the addon module for windows. Please try @tensorflow/tfjs-node @ 1.2.8.

https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v4/1.2.8/tfjs_binding-v1.2.8-node-v64-win32-x64.tar.gz 404 now

chenqing avatar Aug 26 '19 15:08 chenqing

@chenqing the module is uploaded to https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v4/1.2.8/GPU-windows-1.2.8.zip

I notice @d3x0r get the same error. I'll take a look.

kangyizhang avatar Aug 26 '19 16:08 kangyizhang

@kangyizhang Thank you for providing a new version and handling this issue. Unfortunately there was no change with the 1.2.8 version. I still receive the same error as in my initial question.

eggerand13 avatar Aug 26 '19 17:08 eggerand13

@eggerand13 can you try const tf = require('@tensorflow/tfjs-node-gpu'); and let me know if it works? I think you installed tfjs-node-gpu but you are importing tfjs-node.

kangyizhang avatar Aug 26 '19 17:08 kangyizhang

@kangyizhang Ohh I just realized that in my initial post I accidentially wrote tfjs-node instead of tfjs-node-gpu. I edited that part. I do import tfjs-node-gpu. It was just a copy-paste error when writing the issue post. So no, unfortunately that is not the issue.

As you can see from the error, the module is actually loaded. It is in node_modules@tensorflow\tfjs-node-gpu\dist\index.js:44 that the error appears. It seems that somewhere here the problem occurs.

var bindingPath = binary.find(path.resolve(path.join(__dirname, '/../package.json')));
// tslint:disable-next-line:no-require-imports
var bindings = require(bindingPath);

When it tries to load the \node_modules@tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node file (which is referenced in the package.json).

eggerand13 avatar Aug 26 '19 17:08 eggerand13

This is a bug in [email protected] and will be fixed in the next release.

kangyizhang avatar Aug 27 '19 18:08 kangyizhang

Solution? Use:

npm install @tensorflow/[email protected] and

npm install @tensorflow/[email protected]

This solved my problem.

Arturbarth avatar Aug 28 '19 01:08 Arturbarth

@Arturbarth Do you mean using those two installs BEFORE/AFTER using the @tensorflow/tfjs-node-gpu install? Because those two alone will not install tfjs-node-gpu module which this issue here is all about.

I tried using the two installs you proposed BEFORE the @tensorflow/tfjs-node-gpu install which unfortunately did not help.

eggerand13 avatar Aug 28 '19 05:08 eggerand13

@eggerand13 it should work when you only install @tensorflow/[email protected]. We will release a new version soon.

@Arturbarth You only need to install @tensorflow/tfjs-node. @tensorflow/tfjs will be installed when you install @tensorflow/tfjs-node.

kangyizhang avatar Aug 28 '19 06:08 kangyizhang

Just a small note on mine - I did get node-pre-gyp to build it... but it still wouldn't load, even though the file was there. But in my case, this is a Radeon Mobile HD 5850 (from 2009), and being AMD it doesn't have CUDA. (Cuda doesn't have a fall back tp pure CPU mode either, apparently) Just out of curiosity; any work done to use OpenCL instead of CUDA?

d3x0r avatar Aug 28 '19 16:08 d3x0r

@d3x0r thank you,There is no plan for supporting OpenCL but it depends on overall TF Project , you can follow the discussion here. CC @tafsiri

rthadur avatar Aug 28 '19 17:08 rthadur

@kangyizhang Thanks.

@eggerand13 reinstall

npm uninstall @tensorflow/tfjs-node-gpu npm uninstall @tensorflow/tfjs-node

npm update

npm install @tensorflow/[email protected] npm install @tensorflow/[email protected]

Arturbarth avatar Aug 28 '19 19:08 Arturbarth

I still get the above error when I use version 1.2.7 I get a very similar error when I use version 1.2.6 Is there another workaround?

patheros avatar Sep 02 '19 04:09 patheros