question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue running tfjs-node-gpu under Windows

See original GitHub issue

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/tfjs-node-gpu@1.2.7 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 js-ml@1.0.0 No description
npm WARN js-ml@1.0.0 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:34 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
nnt0commented, Sep 9, 2019

@kangyizhang

Okay, i ran node -p "process.arch" and got ia32 back. I then reinstalled Node.js 64 bit, ran the command again and got x64 back. I guess i must have accidentally installed a 32 bit version of node at some point.

I then reinstalled tfjs-node as well as tfjs-node-gpu which completed without any error.

But trying to run either still produced errors. After some testing i found out that everything worked fine in a different directory. After some more testing i found out that a - that i had in a part of a directory caused it to fail. Once i removed the - from the directory everything ran fine.

I am a bit confused about how exactly this - caused everything to fail. I’ve used the same directory with tfjs-node 1.2.1 a while back and it didn’t cause any errors.

Anyhow, thank you very much for helping me figure this out.

1reaction
d3x0rcommented, Aug 25, 2019

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 node-gyp@5.0.3
gyp info using node@12.9.0 | 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).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appendix A. Installing tfjs-node-gpu and its dependencies
js (tfjs-node-gpu) in Node.js, you need to have CUDA and CuDNN installed on your machine. First of all, the machine should be equipped...
Read more >
TensorFlow.js in Node
Like the CPU package, the module that you get will be accelerated by the TensorFlow C binary, however it will run tensor operations...
Read more >
tensorflow/tfjs-node NPM
TensorFlow backend for TensorFlow.js via Node.js. This repository provides native TensorFlow execution in backend JavaScript applications under the Node.js ...
Read more >
@tensorflow/tfjs-node-gpu - npm
Start using @tensorflow/tfjs-node-gpu in your project by running `npm i @tensorflow/tfjs-node-gpu`. There are 64 other projects in the npm ...
Read more >
Tensorboard for Tensorflow.JS under Windows 10
Python v3.8.9; Tensorflow v2.5.0; Tensorflow.JS v3.8.0. I'm using @tensorflow/tfjs-node-gpu , ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found