tfjs-node does not work with Node14 or Node 12 >= 12.17

Created on 8 May 2020  路  7Comments  路  Source: tensorflow/tfjs

TensorFlow.js version

1.7.4

Describe the problem or feature request

This is due to the new N-API-Version '6' which is missing from package.json.

The library builds apparently without issues (as N-API '5'), but the install.js script fails to symlink or copy tensorflow.dll (because folder for N-API '6' does not exist).

Code to reproduce the bug / link to feature request

With node14:

yarn init -y
yarn add "@tensorflow/tfjs-node" (also with "-gpu")
node -r "@tensorflow/tfjs-node"
dir ".\node_modules\@tensorflow\tfjs-node\lib"
dir ".\node_modules\@tensorflow\tfjs-node\lib\napi-v5"
jq .binary.napi_versions ".\node_modules\@tensorflow\tfjs-node\package.json"
(misses version 6)

node.js bug

Most helpful comment

I have created https://github.com/tensorflow/tfjs/pull/3242 to fix this. Please use node version smaller than 14 for now. The next release of this library will support the latest node version.

All 7 comments

Same goes for node v13.12.0
gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (C:\Users\Admin\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:351:16) gyp ERR! stack at ChildProcess.emit (events.js:315:20) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) gyp ERR! System Windows_NT 10.0.18362 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Admin\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--verbose" gyp ERR! cwd C:\Users\Admin\folder\node_modules\@tensorflow\tfjs-node gyp ERR! node -v v13.12.0 gyp ERR! node-gyp -v v6.1.0 gyp ERR! not ok

I have created https://github.com/tensorflow/tfjs/pull/3242 to fix this. Please use node version smaller than 14 for now. The next release of this library will support the latest node version.

As it turns out, Node 12 changed to Napi6 as well starting from 12.17.0;
https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#stable-n-api-release-6 so you have to stick to 12.16.3 for now.

I'm not 100% sure but TFJS-node 2.0.0 was released 2 weeks ago or so, I think it now has Napi6 support?

Well, maybe, yes. Unfortunately, currently it seems I still need to use tensorflow 1.15.

"@tensorflow/tfjs": "^2.6.0",
"@tensorflow/tfjs-node": "^2.6.0",
node_version: "12.19.0"

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

Error: The specified module could not be found.
\?\C:\Users..\node_modules\@tensorflow\tfjs-node\lib\napi-v6\tfjs_binding.node

"@tensorflow/tfjs": "^2.6.0",
"@tensorflow/tfjs-node": "^2.6.0",
node_version: "12.19.0"

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

Error: The specified module could not be found.
\?\C:\Users..\node_modules@tensorflow\tfjs-node\lib\napi-v6\tfjs_binding.node

I used node 12.16.1 and It found the specified module, however I still get notice: Hi there. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdonahue picture chrisdonahue  路  3Comments

RELNO picture RELNO  路  3Comments

lastnod picture lastnod  路  3Comments

JasonShin picture JasonShin  路  4Comments

nsthorat picture nsthorat  路  3Comments