When I try to install @tensorflow/tfjs-gpu in node.js, I get this error:
PS C:Userstobia2d-classification> npm i @tensorflow/tfjs-node-gpu --force
npm WARN using --force Recommended protections disabled.
npm ERR! code 1
npm ERR! path C:Userstobia2d-classificationnode_modules@tensorflowtfjs-node-gpu
npm ERR! command failed
npm ERR! command C:WINDOWSsystem32cmd.exe /d /s /c node scripts/install.js gpu download
npm ERR! GPU-windows-4.9.0.zip
npm ERR! https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-2.9.1.zip
npm ERR! * Downloading libtensorflow
npm ERR!
npm ERR! * Building TensorFlow Node.js bindings
npm ERR! symlink ./lib/napi-v9 failed: Error: Command failed: node scripts/deps-stage.js symlink ./lib/napi-v9
npm ERR! * Symlink of libnapi-v9tensorflow.dll failed, creating a copy on disk.
npm ERR! node:internal/process/promises:289
npm ERR! triggerUncaughtException(err, true /* fromPromise */);
npm ERR! ^
npm ERR!
npm ERR! [Error: ENOENT: no such file or directory, copyfile 'C:Userstobia2d-classificationnode_modules@tensorflowtfjs-node-gpudepslibtensorflow.dll' -> 'C:Userstobia2d-classificationnode_modules@tensorflowtfjs-node-gpulibnapi-v9tensorflow.dll'] {
npm ERR! errno: -4058,
npm ERR! code: 'ENOENT',
npm ERR! syscall: 'copyfile',
npm ERR! path: 'C:\Users\tobia\2d-classification\node_modules\@tensorflow\tfjs-node-gpu\deps\lib\tensorflow.dll',
npm ERR! dest: 'C:\Users\tobia\2d-classification\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v9\tensorflow.dll'
npm ERR! }
npm ERR!
npm ERR! Node.js v20.5.0
npm ERR!
npm ERR! at ChildProcess.exithandler (node:child_process:421:12)
npm ERR! at ChildProcess.emit (node:events:514:28)
npm ERR! at maybeClose (node:internal/child_process:1105:16)
npm ERR! at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
npm ERR! code: 1,
npm ERR! killed: false,
npm ERR! signal: null,
npm ERR! cmd: 'node scripts/deps-stage.js symlink ./lib/napi-v9'
npm ERR! }
npm ERR! A complete log of this run can be found in: C:UserstobiaAppDataLocalnpm-cache_logs2023-07-22T13_17_27_507Z-debug-0.log
PS C:Userstobia2d-classification>
I did install @tensorflow/tfjs first as the official guide mentioned and I did also install cuda, copied the file in the cuDNN SDK and I also installed python.
I tried using windows cmd, vsc terminal, adding –force, … pls help 😅
2
Answers
Make sure you are using the latest version of Node.js and NPM. TensorFlow.js may have issues with outdated versions of Node.js
Delete the
node_modules
folder and thepackage-lock.json
file, and run npm install again to reinstall all dependencies:If the problem persists, you can try installing the CPU version of TensorFlow.js (@tensorflow/tfjs-node) instead of the GPU version to see if this works:
Maybe problem in Node20, bacause in Node18 I had this problem fixed whith:
https://github.com/tensorflow/tfjs/blob/master/tfjs-node/README.md
https://github.com/tensorflow/tfjs/blob/master/tfjs-node/WINDOWS_TROUBLESHOOTING.md
https://github.com/nodejs/node-gyp#on-windows