Skip to content

Missing napi-v9 Support in napi_versions in package.json for tfjs-node-gpu #8542

Closed
@lsby

Description

@lsby

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

  1. Installed @tensorflow/tfjs-node-gpu using npm install @tensorflow/tfjs-node-gpu (or pnpm install).

  2. 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
    
  3. I checked the lib folder under node_modules/@tensorflow/tfjs-node-gpu/ and found the following:

    • napi-v8 folder contains the tfjs_binding.node file.
    • napi-v9 folder contains the tensorflow.dll file, but no .node file is present.
  4. I then checked the package.json file in the node_modules/@tensorflow/tfjs-node-gpu folder. In the "binary" section, I noticed that the napi_versions array only listed versions 3, 4, 5, 6, 7, 8, and did not include version 9. (

    "napi_versions": [
    )

  5. Based on my findings, I added 9 to the napi_versions array in package.json:

    "napi_versions": [ 3, 4, 5, 6, 7, 8, 9 ]
  6. After making this change, I ran the rebuild command (pnpm rebuild @tensorflow/tfjs-node-gpu) to ensure that the proper binary for napi-v9 would be downloaded.

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions