Skip to content

Cannot import @tensorflow/tfjs-node-gpu on Windows #2003

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

Closed
gobboo opened this issue Sep 9, 2019 · 55 comments
Closed

Cannot import @tensorflow/tfjs-node-gpu on Windows #2003

gobboo opened this issue Sep 9, 2019 · 55 comments
Assignees

Comments

@gobboo
Copy link

gobboo commented Sep 9, 2019

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

@kangyizhang
Copy link
Contributor

hi @Mobles, quick question: are you seeing the same issue when using @tensorflow/tfjs-node package?

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

@kangyizhang Nope, that works fine, I have had that issue when using it once but I fixed it by doing
npm rebuild @tensorflow/tfjs-node --build-from-source

This doesn't fix it for tfjs-node-gpu though :/

@kangyizhang
Copy link
Contributor

hi @Mobles

Other users has the same issue and I'm dedicated to fixing it. However I can not reproduce it on my windows machine, I need some of your help.

Can you

  1. Fork the @tensorflow/tfjs repo: https://github.com/tensorflow/tfjs
  2. go to tfjs-node directory
  3. add console.log('bindingPath: ', bindingPath); at this line: https://github.com/tensorflow/tfjs/blob/master/tfjs-node/src/index.ts#L29
  4. run yarn && yarn test, this will print out the bindingPath value and start to run tests locally. You can need to wait for all the tests, fill free to Ctrl+c to terminate the tests.
  5. paste the bindingPath value here

Thank you!
5.

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

bindingPath: D:\Programming\NodeJS Work\dumb-doorbell\server\test\tfjs\tfjs-node\lib\napi-v4\tfjs_binding.node

The tests failed anyhow

Failures:
1) computation in worker (node env) test-tensorflow {} tensor in worker
  Message:
    Error: Cannot find module './dist/index.js'

@kangyizhang
Copy link
Contributor

Thanks a lot for the update!

The path looks fine. And if the test could start, the module could be loaded correctly. The problem should be related with the published npm package. I'll look into it.

FYI the failed test is unrelated.

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

Ah okay, thanks for the assistance !

@kangyizhang kangyizhang self-assigned this Sep 9, 2019
@kangyizhang
Copy link
Contributor

@Mobles I can reproduce the issue. It's because of the space in your path. Space in path is not supported by the binding tool node-gyp. Please try to move it to a folder without space and let me know if the error still exist.

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

Nope, same error, no spaces in my file path

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

Error: The specified module could not be found.
\\?\D:\Programming\NodeJS\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\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)

@kangyizhang
Copy link
Contributor

@Mobles did you delete node_module and reinstall dependencies?

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

Yup, I deleted the folder and typed
npm install

@kangyizhang
Copy link
Contributor

@Mobles can you try go to the @tensorflow/tfjs-node-gpu directory, like cd node_modules\@tensorflow\tfjs-node-gpu, then run node-pre-gyp rebuild (you might need to npm install -g node-pre-gyp). Then see if you can import tfjs-node-gpu?

@kangyizhang
Copy link
Contributor

@Mobles I can not reproduce the error on my machine but another user says removing - helps: #1912 (comment)

@gobboo
Copy link
Author

gobboo commented Sep 9, 2019

Hi @kangyizhang

Both the above solutions didn't work, the first one gave me this error:

D:\Programming\NodeJS\dumbdoorbell\server\node_modules\@tensorflow\tfjs-node-gpu>node-pre-gyp rebuild
node-pre-gyp info it worked if it ends with ok    
node-pre-gyp info using [email protected]       
node-pre-gyp info using [email protected] | win32 | x64
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd clean' (Error: spawn node-gyp.cmd ENOENT)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\Billy\AppData\Roaming\npm\node_modules\node-pre-gyp\lib\util\compile.js:77:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
node-pre-gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
node-pre-gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
node-pre-gyp ERR! System Windows_NT 10.0.18362
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Billy\\AppData\\Roaming\\npm\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "rebuild"
node-pre-gyp ERR! cwd D:\Programming\NodeJS\dumbdoorbell\server\node_modules\@tensorflow\tfjs-node-gpu
node-pre-gyp ERR! node -v v12.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd clean' (Error: spawn node-gyp.cmd ENOENT)

and the second one the same error still persists, removing the - didn't help

Ignore the above error, fixed it by installing node-gyp globally! Didn't fix it though

@adwellj
Copy link

adwellj commented Sep 10, 2019

@kangyizhang, I'm in the same boat.

PS C:\Users\Josh\source\repos\tfjs-training-classification> node
> const tfjs = require("@tensorflow/tfjs-node-gpu");
Thrown:
Error: The specified module could not be found.
\\?\C:\Users\Josh\source\repos\tfjs-training-classification\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:807: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:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)

This is also after trying your suggestion of node-pre-gyp rebuild.

Please let me know if there's anything I can do to assist in troubleshooting.

@kangyizhang
Copy link
Contributor

@Mobles I still can not reproduce this error, but I found this question. Can you follow the answer in this question and install windows-build-tools, then try again?

@adwellj can you try to 1) see if it works after remove - in the folder name 2) try the above steps?

@gobboo
Copy link
Author

gobboo commented Sep 10, 2019

@kangyizhang Nope, didn't fix it, the windows-build-tools wouldn't install for a good hour, just this message

start --quiet --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --locale en-US --activityId 4c3f742b-c601-4f20-9a79-3852c0250993] +0ms
  windows-build-tools ------------------- Python -------------------- +0ms
  windows-build-tools Python 2.7.16 is already installed, not installing again. +0ms
  windows-build-tools ---------- Visual Studio Build Tools ---------- +498ms
  windows-build-tools 2019-09-10T20:34:00 : Verbose : [InstalledProductsProviderImpl]: Stream was closed +0ms
  windows-build-tools 2019-09-10T20:34:00 : Verbose : [InstallerImpl]: Rpc connection was closed. +1ms
  windows-build-tools 2019-09-10T20:34:00 : Verbose : [InstallerImpl]: Stream was closed +0ms
  windows-build-tools 2019-09-10T20:34:00 : Verbose : Completed notifying all clients that the update is starting +0ms
  windows-build-tools 2019-09-10T20:34:00 : Verbose : Updating installer [bootstrapperArguments: /finalizeInstall install --in C:\ProgramData\Microsoft\VisualStudio\Packages\_bootstrapper\vs_setup_bootstrapper_201909102033434738.json --norestart --quiet --includeRecommended --add Microsoft.VisualStudio.Workload.VCTools --locale en-US --activityId 4c3f742b-c601-4f20-9a79-3852c0250993] +0ms

So I cancelled it, and tried again and it installed but running my program again didn't work and got the same error.

Just saw the Dependancy Walker comment, got this

Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Error: A circular dependency was detected.
Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Andddd I'm missing a ton of modules:

https://pastebin.com/6HSpRvKv

Any particular package that has all of these in?

@adwellj
Copy link

adwellj commented Sep 11, 2019

@kangyizhang tried it in a brand new repo without any hyphens in the name. Same result.
I then realized that I forgot to add the location for cuDNN and other CUDA directories to my path. Once I included those and launch a new PowerShell window, everything seems to be working.

@Mobles for reference, I'm using CUDA toolkit 10.0.130 and cuDNN 10.0 version 7.4.2.24.
I've copied the contents of cuDNN to a directory of "C:\tools". I have the following entries in my user path variable:

  • C:\tools\cuda\bin
  • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin
  • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\libx64
  • C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include

Hopefully this will be of benefit to you :)

Creating a new project with a hyphen in the name:

PS C:\Users\Josh\source\repos\gpu-1-2-9> npm init -y
Wrote to C:\Users\Josh\source\repos\gpu-1-2-9\package.json:

{
  "name": "gpu-1-2-9",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


PS C:\Users\Josh\source\repos\gpu-1-2-9> npm i @tensorflow/tfjs-node-gpu

> @tensorflow/[email protected] install C:\Users\Josh\source\repos\gpu-1-2-9\node_modules\@tensorflow\tfjs-node-gpu
> node scripts/install.js gpu download

GPU-windows-1.2.9.zip
* Downloading libtensorflow
[==============================] 11287391/bps 100% 0.0s
[==============================] 1736527/bps 100% 0.0s
* Building TensorFlow Node.js bindings
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ @tensorflow/[email protected]
added 86 packages from 84 contributors and audited 150 packages in 37.991s
found 0 vulnerabilities

PS C:\Users\Josh\source\repos\gpu-1-2-9> node
> const tf = require("@tensorflow/tfjs-node-gpu");
2019-09-11 08:05:14.734299: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-09-11 08:05:14.741308: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library nvcuda.dll
2019-09-11 08:05:14.814634: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties:
name: GeForce GTX 1660 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.845
pciBusID: 0000:01:00.0
2019-09-11 08:05:14.820344: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
2019-09-11 08:05:14.824137: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0
2019-09-11 08:05:15.383664: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-09-11 08:05:15.387720: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187]      0
2019-09-11 08:05:15.389994: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0:   N
2019-09-11 08:05:15.392695: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4637 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1660 Ti, pci bus id: 0000:01:00.0, compute capability: 7.5)
undefined
>

Edit: Corrected cuDNN version from 7.6 to 7.4

@gobboo
Copy link
Author

gobboo commented Sep 11, 2019

@adwellj

I had already got those path variables,

image

They didn't help though, I'm going to try reinitalize my project, see what that does.

Edit: Nope, same error :/
Update:
Works on WSL lmao but just not windows in general???

> const tf = require("@tensorflow/tfjs-node-gpu");
Thrown:
Error: The specified module could not be found.
\\?\D:\Programming\NodeJS\dumbdoorbell\test\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)
>

@adwellj
Copy link

adwellj commented Sep 11, 2019

@Mobles bummer :(
It worked immediately on that gpu-1-2-9 project (after restarting PowerShell), but it still failed on my original tfjs-training-classification project. For that one I did an npm uninstall @tensorflow/tfjs-node-gpu followed by an npm i @tensorflow/tfjs-node-gpu. It worked after that.

Have you tried creating a new project with only tfjs-node-gpu to isolate it down to just this package?

@gobboo
Copy link
Author

gobboo commented Sep 11, 2019

@adwellj
Yeah, tried it in the above bit, made it on my desktop and tried to import it and the same error :(

@adwellj
Copy link

adwellj commented Sep 11, 2019

@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 step node-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.

@kangyizhang
Copy link
Contributor

@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

@adwellj
Copy link

adwellj commented Sep 11, 2019

Good catch @kangyizhang! I didn't notice the 10.1 in his path variables.

FYI, cuDNN version 7.6.2.24 does not work. It will generate a 'could not create cudnn handle' exception once I try to perform some operations. I just found that out about an hour ago 😏
Replacing it with 7.4.2.24 resolved that issue.

@gobboo
Copy link
Author

gobboo commented Sep 12, 2019

Hi @kangyizhang

That unfortunately didn't help :/ Same error

D:\Programming\NodeJS\dumbdoorbell\server>node .
internal/modules/cjs/loader.js:977
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The specified module could not be found.
\\?\D:\Programming\NodeJS\dumbdoorbell\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\dumbdoorbell\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)

@gobboo
Copy link
Author

gobboo commented Sep 12, 2019

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

@DouglasLivingstone
Copy link

I've also been having this problem, it seems to be related to the Node version installed. When I run yarn && yarn test under Node v12.13.0 (current LTS, in a git bash shell on Windows 10) I get this error:

$ yarn && yarn test
yarn install v1.19.1
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "@tensorflow/tfjs > @tensorflow/[email protected]" has unmet peer dependency "seedrandom@~2.4.3".
[5/5] Building fresh packages...
$ node scripts/install.js
CPU-windows-1.3.1.zip
* Downloading libtensorflow
[==============================] 4557291/bps 100% 0.0s
[==============================] 1548229/bps 100% 0.0s
* Building TensorFlow Node.js bindings
Done in 17.94s.
yarn run v1.19.1
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\dev\tfjs\tfjs-node\src\index.ts:32:18)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Module.m._compile (C:\dev\tfjs\tfjs-node\node_modules\ts-node\src\index.ts:400:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Object.require.extensions.<computed> [as .ts] (C:\dev\tfjs\tfjs-node\node_modules\ts-node\src\index.ts:403:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It seems like some of the output didn't render properly (there were some blank lines) but it looks the same as @ealionel's output.

However, if I uninstall Node v12.13 and install Node v11.15 instead, it runs the tests:

$ yarn && yarn test
yarn install v1.19.1
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "@tensorflow/tfjs > @tensorflow/[email protected]" has unmet peer dependency "seedrandom@~2.4.3".
[5/5] Building fresh packages...

$ node scripts/install.js
CPU-windows-1.3.1.zip
* Downloading libtensorflow
[==============================] 4238173/bps 100% 0.0s
[==============================] 2294696/bps 100% 0.0s
* Building TensorFlow Node.js bindings
Done in 25.78s.
yarn run v1.19.1
Started
.............[snip].............

Failures:
1) computation in worker (node env) test-tensorflow {} tensor in worker
  Message:
    Error: Cannot find module './dist/index.js'
  Stack:
    error properties: Object({ code: 'MODULE_NOT_FOUND' })
        at <Jasmine>
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
        at Function.Module._load (internal/modules/cjs/loader.js:591:27)
        at Module.require (internal/modules/cjs/loader.js:723:19)
        at require (internal/modules/cjs/helpers.js:14:16)
        at [worker eval]:4:14
        at [worker eval]:10:3
        at Script.runInThisContext (vm.js:124:20)
        at Object.runInThisContext (vm.js:314:38)
        at Object.<anonymous> ([worker eval]-wrapper:9:26)
        at Module._compile (internal/modules/cjs/loader.js:816:30)
  Message:
    Failed: Cannot find module './dist/index.js'
  Stack:
    error properties: Object({ code: 'MODULE_NOT_FOUND' })
        at <Jasmine>
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
        at Function.Module._load (internal/modules/cjs/loader.js:591:27)
        at Module.require (internal/modules/cjs/loader.js:723:19)
        at require (internal/modules/cjs/helpers.js:14:16)
        at [worker eval]:4:14
        at [worker eval]:10:3
        at Script.runInThisContext (vm.js:124:20)
        at Object.runInThisContext (vm.js:314:38)
        at Object.<anonymous> ([worker eval]-wrapper:9:26)
        at Module._compile (internal/modules/cjs/loader.js:816:30)

Ran 3526 of 3593 specs
3526 specs, 1 failure
Finished in 5.446 seconds
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I think that it is also broken in Node v10.

@kangyizhang
Copy link
Contributor

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.

@kangyizhang
Copy link
Contributor

@DouglasLivingstone do you see the same error with tfjs-node for version 1.2.9 or 1.2.10?

@JoshNewham1
Copy link

JoshNewham1 commented Oct 31, 2019

I'm having the exact same issue on a new Windows machine under Node v12.13.0. I've installed Python 2 and the dev tools with absolutely no problems. I can build the bindings and can confirm that they exist, but I get the same import error. This is with TFJS-Node version 1.3.1.

On my other system, I managed to get it to work perfectly with Node v10.16.3, TFJS v1.2.11 and TFJS-Node v1.2.9. I've no idea why this worked, and trying to update any packages results in the "module not found" issue for "tfjs_binding.node". Both of these systems are on Windows 10 1903.

@adwellj
Copy link

adwellj commented Oct 31, 2019

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.

@thohag
Copy link

thohag commented Oct 31, 2019

I have the same error running [email protected] with node 12.13.0.
Using node 10.16.3 seems to fix it.

@MarcDelp
Copy link

Hi, same error here on Windows 10 as well:

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

Error: The specified module could not be found.
\\?\C:\Users\madelpech\Documents\Projets\TFJS\node_modules\@tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1025:18)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Users\madelpech\Documents\Projets\TFJS\node_modules\@tensorflow\tfjs-node\dist\index.js:44:16)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)

Node version: 12.13.1
Tried with tfjs-node versions: 1.3.1, 1.3.0, 1.27
I always have the file tfjs_binding.node in the folder node_modules/tfjs-node/lib/napi-v4.

Side note: I can't install [email protected], even if I have tried installing (and reinstalling) windows-build-tools and other solutions found on this github and on the Internet.

@adwellj
Copy link

adwellj commented Nov 27, 2019

@MarcDelp, I'm pretty sure there's an issue with tfjs and node 12, and the latest version of node to be working is 10.16.3. Perhaps try with node 10.16.3 and see if that temporarily resolves your issue.

@MarcDelp
Copy link

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?

@kangyizhang
Copy link
Contributor

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

@rthadur rthadur closed this as completed Nov 28, 2019
@JoshNewham1
Copy link

JoshNewham1 commented Dec 21, 2019

If this problem is still affecting anyone, I think I might've found a temporary fix. I transplanted the tensorflow.dll file from my Node v10.16.3 modules (node_modules@tensorflow\tfjs-node\lib\napi-v4) to my Node 12 modules which didn't seem to have one. Then, I got past the "specified module could not be found" error. This is quite a bad bodge and definitely not a solution for production environments but seems to work fine for development until this issue is fixed. The DLL file is hosted here, if you can't find it.

@kangyizhang
Copy link
Contributor

This issue should have been fixed @v1.4.0 and later. Please feel free to let me know if you are still seeing any error.

@JoshNewham1
Copy link

Yeah, sorry, it has been fixed, I was still on an old version. Thanks for the update 😁.

@mprinc
Copy link

mprinc commented Feb 22, 2020

@kangyizhang Still the same error "Error: Cannot find module '.../node_modules/@tensorflow/tfjs-node/lib/napi-v5/tfjs_binding.node'"

macOS Catalina
v10.15.03

node -v
v12.13.0

"name": "@tensorflow/tfjs-node",
"version": "1.5.2",

"name": "@tensorflow/tfjs",
"version": "1.5.2",

"name": "@tensorflow/tfjs-core",
"version": "1.5.2"

@mprinc
Copy link

mprinc commented Feb 22, 2020

OK, binary searching :( versions I came to the latest working solution:

node -v
v12.10.0
(the next v12.11.1 is crashing, also the same with the currently latest node v13.9.0)

"name": "@tensorflow/tfjs-node",
"version": "1.4.0",
(the next 1.5.1 is crashing)


Obviously, this is far from ideal as we need to propagate node version changes on the production servers, and as we have both frontend and backend tf, we need to reduce frontend version to not risk compatibility issues or keep them version-async


we are happy to create minimal test case and provide whatever info to be able to work with the latest versions of tf and node

@mprinc
Copy link

mprinc commented Feb 23, 2020

It is even worse with our servers, @kangyizhang
I couldn't find any working combination and I tried with many versions of node, tensorflow, etc

Here is the server info
Linux aitool 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Ubuntu 18.04.4 LTS

@adwellj
Copy link

adwellj commented Feb 23, 2020

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.

@mprinc
Copy link

mprinc commented Feb 23, 2020

Thanks, @adwellj, it is a regular server, without GPU server, as there is no demanding TF use case. I tried various combinations, but I couldn't find a working option, I started with the latest versions of nodes and tfjs, but then followed various suggestions with using earlier versions. With OSX it helped, but Ubuntu is even worse

EDIT: With the latest v1.7.0 Ubuntu is resolved. I get expected warning :) "Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA"

@EddieOne
Copy link
Contributor

\?\C:\Users\eddie\Documents\GitHub\Y8-Instant-io-Game\node_modules@tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node

Works fine on a clean install but on a machine that has had many versions of node, getting some extra slashes \\?\ seems incorrect.

@andrefantinato
Copy link

I'm having the exact same issue on a new Windows machine under Node v12.13.0. I've installed Python 2 and the dev tools with absolutely no problems. I can build the bindings and can confirm that they exist, but I get the same import error. This is with TFJS-Node version 1.3.1.

On my other system, I managed to get it to work perfectly with Node v10.16.3, TFJS v1.2.11 and TFJS-Node v1.2.9. I've no idea why this worked, and trying to update any packages results in the "module not found" issue for "tfjs_binding.node". Both of these systems are on Windows 10 1903.

Thanks @JoshNewham1, save my project =D

@DrewJay
Copy link

DrewJay commented Sep 20, 2020

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:

If this problem is still affecting anyone, I think I might've found a temporary fix. I transplanted the tensorflow.dll file from my Node v10.16.3 modules (node_modules@tensorflow\tfjs-node\lib\napi-v4) to my Node 12 modules which didn't seem to have one. Then, I got past the "specified module could not be found" error. This is quite a bad bodge and definitely not a solution for production environments but seems to work fine for development until this issue is fixed. The DLL file is hosted here, if you can't find it.

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.

@EvangelosKolimitras
Copy link

EvangelosKolimitras commented Nov 27, 2020

@Mobles can you try go to the @tensorflow/tfjs-node-gpu directory, like cd node_modules\@tensorflow\tfjs-node-gpu, then run node-pre-gyp rebuild (you might need to npm install -g node-pre-gyp). Then see if you can import tfjs-node-gpu?

I had the same issue and I ran node-pre-gyp rebuild and got this output:
image
Along with a whole bunch of more above.

I keep getting the same error:
image
My path does not contain any spaces.

@Omkaragrawal
Copy link

I am getting the same issue with both tfjs-node and tfjs-node-gpu, some of previous versions were running properly, but are not working now.

Versions of my system:
tfjs-node: 2.7.0
node: 14.15.3
npm: 6.14.10

Please help

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

No branches or pull requests