tfjs: Cannot import @tensorflow/tfjs-node-gpu on Windows
To get help from the community, we encourage using Stack Overflow and the tensorflow.js
tag.
TensorFlow.js version
1.2.9
Browser version
Using NodeJS: v12.10.0
Describe the problem or feature request
Cannot import @tensorflow/tfjs-node-gpu at all, only @tensorflow/tfjs-node but I’d like to use my GPU.
Code to reproduce the bug / link to feature request
require(‘@tensorflow/tfjs-node-gpu’);
Here is the error:
`internal/modules/cjs/loader.js:977 return process.dlopen(module, path.toNamespacedPath(filename)); ^
Error: The specified module could not be found. \?\D:\Programming\NodeJS Work\dumb-doorbell\server\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> (D:\Programming\NodeJS Work\dumb-doorbell\server\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’ve tried reinstalling all my modules, tried using Recommended Node version, tried rebuilding the package, idk what else to try so I’m hoping to get some way to fix this from here
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 55 (17 by maintainers)
@MarcDelp @adwellj A PR fixing this issue has been merged and the next release (most likely after thankgiving) will support the latest version of node.
Right, turns out I fixed it? Some how???
Idk how I did but it had nothing to do with NodeJS? I was looking at Voice Mimicing with AI, installed some Python 3.7 libraries, one of which being Tensorflow GPU & PyTorch, now it’s suddenly working
I legit have 0 clue as to what got it working 😕
I have the same error running tfjs-node@1.3.1 with node 12.13.0. Using node 10.16.3 seems to fix it.
I too had problems running newer versions of tfjs on newer versions of Node on Windows 10.
Node v10.17.0 and tfjs 1.2.11 would produce a ‘module not found’ error when trying to
require("@tensorflow/tfjs-node")
. Node v10.16.3 and tfjs 1.2.11 will work though, as JoshNewham1 mentioned above.I had the same issue and I ran node-pre-gyp rebuild and got this output:
Along with a whole bunch of more above.
I keep getting the same error:
My path does not contain any spaces.
I would like to underline the fact that this problem is not resolved. I’ve tried everything mentioned above without any success to get tjfs-node-gpu working on windows 10. It always yields
UnhandledPromiseRejectionWarning: Error: The Node.js native addon module (tfjs_binding.node) can not be found at path: C:\...\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node.
.It feels like finding right versions of node.js + tfjs + tfjs-node-gpu is purely experimental task which is a little frustrating. Also I have to mention that tfjs works well on CPU.
UPDATE: So it turns out adding tensorflow.dll as mentioned in comment below actually did the job:
The final set of configurations working for me seem to be following: Node.js:
v10.16.3
@tensorflow/tfjs:v1.2.11
@tensorflow/tfjs-node:v1.2.9
@tensorflow/tfjs-node-gpu:v1.2.9
CUDA toolkit:v10.0.0
cuDNN sdk:any version compatible with CUDA toolkit v10.0.0 - so for example v7.4.2
And don’t forget adding required CUDA paths into env PATH.
Thanks @JoshNewham1, save my project =D
I’ve recently found that starting with node 12.15, you need to be on tfjs-node-gpu 1.5.x. Below 12.15 requires 1.4.0 (or below).
Also, tfjs-node-gpu 1.5.x requires CuDNN 7.6, whereas earlier versions used 7.4.
I hope this helps you guys. The poor / incomplete documentation regarding version compatibility is frustrating.
Yes, I got it working on node 10.16.3 with tfjs 1.3.1 but I’d really like to make it on node 12 as we are starting a new project from scratch. Do you have any idea (even if not a precise one) on when the fix may be available?
hi @ealionel
I can reproduce the error on a new windows machine (though it works on the windows machine we use to develop). I’ll try to figure out the reason.
@Mobles can you try with CUDA 10.0 and cuDNN >= 7.4.1? These are the official supported version: https://www.tensorflow.org/install/gpu
@Mobles unsure if this is relevant, but here are some additional things I had done previously to this new PC. They’re steps that I used to have to do for version 0.3.2 when tfjs-node-gpu was using node-gyp to build on the client.
npm i -g node-gyp
Then from an elevated console (Run as Administrator)npm i -g --production windows-build-tools
Then create a copy of python.exe in C:\Users<user>.windows-build-tools\python27 and rename it to python2.exe. Without this stepnode-gyp configure --verbose
would complain about not being able to find python2.My understanding is that node-gyp is no longer needed, so this is likely not relevant, but these are some other configurations that I’ve made to this new machine.