Description
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): windows 11
- TensorFlow.js installed from (npm or script link): pnpm i @tensorflow/tfjs-node-gpu
- TensorFlow.js version: "@tensorflow/tfjs-node-gpu": "4.22.0"
- CUDA/cuDNN version: 11.8
- node version: v22.13.1
- pnpm version: 9.15.4
Describe the problem
The issue arises when using Node.js napi version 9 with @tensorflow/tfjs-node-gpu. When attempting to use the pre-built binary, the .node file corresponding to napi-v9 is missing, and instead, there is only a .dll file under napi-v9. This happens because the napi_versions array in the package.json for @tensorflow/tfjs-node-gpu doesn't include 9.
Provide the exact sequence of commands / steps that you executed before running into the problem
-
Installed
@tensorflow/tfjs-node-gpu
usingnpm install @tensorflow/tfjs-node-gpu
(orpnpm install
). -
Ran my TensorFlow.js code, and encountered an error regarding the missing
.node
file.- The error message indicated that it was trying to load a
.node
file, but it couldn't be found in the expected path:
Error: The specified module could not be found. \\?\D:\Code\playground-ts-tensorflow\node_modules\.pnpm\@[email protected]\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v8\tfjs_binding.node
- The error message indicated that it was trying to load a
-
I checked the
lib
folder undernode_modules/@tensorflow/tfjs-node-gpu/
and found the following:napi-v8
folder contains thetfjs_binding.node
file.napi-v9
folder contains thetensorflow.dll
file, but no.node
file is present.
-
I then checked the
package.json
file in thenode_modules/@tensorflow/tfjs-node-gpu
folder. In the"binary"
section, I noticed that thenapi_versions
array only listed versions3, 4, 5, 6, 7, 8
, and did not include version 9. (tfjs/tfjs-node-gpu/package.json
Line 80 in 2644bd0
-
Based on my findings, I added
9
to thenapi_versions
array inpackage.json
:"napi_versions": [ 3, 4, 5, 6, 7, 8, 9 ]
-
After making this change, I ran the rebuild command (
pnpm rebuild @tensorflow/tfjs-node-gpu
) to ensure that the proper binary fornapi-v9
would be downloaded. -
After rebuilding, the issue was resolved, and the package worked correctly without the error.
Any other info / logs
Here’s the error message I encountered:
Error: The specified module could not be found.
\\?\D:\Code\playground-ts-tensorflow\node_modules\.pnpm\@[email protected]\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v8\tfjs_binding.node