Skip to content
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

Error when installing(?) and crash upon importing #4625

Closed
LPugens opened this issue Feb 1, 2021 · 10 comments
Closed

Error when installing(?) and crash upon importing #4625

LPugens opened this issue Feb 1, 2021 · 10 comments

Comments

@LPugens
Copy link

LPugens commented Feb 1, 2021

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: Electron app
  • TensorFlow.js installed from (npm or script link): npm
  • TensorFlow.js version: @tensorflow/tfjs-node@3.0.0
  • CUDA/cuDNN version: None

Describe the problem
While installing tfjs-node, I get an weird message, which I'm not sure is an error.
When importing thee library I get a crashing error, as seen below.

Provide the exact sequence of commands / steps that you executed before running into the problem
Installing:

PS C:\Users\lfernandes\folder_sorter\my-electron-app> npm install @tensorflow/tfjs-node --build-from-source      

> @tensorflow/tfjs-node@3.0.0 install C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node
> node scripts/install.js

CPU-windows-3.0.0.zip
* Downloading libtensorflow
[==============================] 6079896/bps 100% 0.0s
* Building TensorFlow Node.js bindings
symlink ./lib/napi-v7 failed:  null
npm WARN my-electron-app@1.0.0 No description
npm WARN my-electron-app@1.0.0 No repository field.

+ @tensorflow/tfjs-node@3.0.0
added 107 packages from 65 contributors and audited 200 packages in 27.77s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

I find the line symlink ./lib/napi-v7 failed: null really weird. Maybe the root of the error below is here, however I could not find any info regarding this message.

Importing:

const tf = require('@tensorflow/tfjs-node');

Any other info / logs

importing error:

Uncaught Error: The Node.js native addon module (tfjs_binding.node) can not be found at path: C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node\lib\napi-v6\tfjs_binding.node. 
Please run command 'npm rebuild @tensorflow/tfjs-node build-addon-from-source' to rebuild the native addon module. 
If you have problem with building the addon module, please check https://github.com/tensorflow/tfjs/blob/master/tfjs-node/WINDOWS_TROUBLESHOOTING.md or file an issue.
    at Object.<anonymous> (C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node\dist\index.js:49:11)
    at Object.<anonymous> (C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node\dist\index.js:81:3)
    at Module._compile (internal/modules/cjs/loader.js:1152:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:10)
    at Module.load (internal/modules/cjs/loader.js:992:32)
    at Module._load (internal/modules/cjs/loader.js:885:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12738)
    at Module.require (internal/modules/cjs/loader.js:1032:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Users\lfernandes\folder_sorter\my-electron-app\renderer.js:3:12)

In case I try the fix suggested in the error message, I still get the same weird message symlink ./lib/napi-v7 failed: null while the importing error persists:

PS C:\Users\lfernandes\folder_sorter\my-electron-app> npm rebuild @tensorflow/tfjs-node --build-addon-from-source

> @tensorflow/tfjs-node@3.0.0 install C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node
> node scripts/install.js

CPU-windows-3.0.0.zip
* Building TensorFlow Node.js bindings
symlink ./lib/napi-v7 failed:  null

I am new to javascript and node, so please tell me if you need any other info.

@LPugens LPugens changed the title symlink ./lib/napi-v7 failed: null Error when installing(?) and crash upon importing Feb 1, 2021
@rthadur
Copy link
Contributor

rthadur commented Feb 1, 2021

There is underlying issue with windows , you need to manually copy files from deps/lib to node_modules/@tensorflow/tfjs-node/lib/napi-v7.

@LPugens
Copy link
Author

LPugens commented Feb 1, 2021

Still the same issue.
I noticed the tensorflow.dll is identical in both folders:

Filename CRC32
lib\napi-v7\tensorflow.dll E02CB98E
lib\napi-v7\tfjs_binding.node 30D2AFF5
deps\lib\tensorflow.dll E02CB98E
deps\lib\tensorflow.lib 2AA0937C

Any other ideas?

@rthadur
Copy link
Contributor

rthadur commented Feb 2, 2021

can you delete tensorflow.dll in deps\lib and try again

@LPugens
Copy link
Author

LPugens commented Feb 2, 2021

Tried the following with the same results:

PS C:\Users\lfernandes\folder_sorter\my-electron-app> npm uninstall @tensorflow/tfjs-node
npm WARN my-electron-app@1.0.0 No description
npm WARN my-electron-app@1.0.0 No repository field.   

removed 107 packages and audited 93 packages in 3.478s

7 packages are looking for funding
  run `npm fund` for details      


PS C:\Users\lfernandes\folder_sorter\my-electron-app> npm install @tensorflow/tfjs-node --build-from-source

> @tensorflow/tfjs-node@3.0.0 install C:\Users\lfernandes\folder_sorter\my-electron-app\node_modules\@tensorflow\tfjs-node  
> node scripts/install.js

CPU-windows-3.0.0.zip
* Downloading libtensorflow
[==============================] 2681425/bps 100% 0.0s
* Building TensorFlow Node.js bindings
symlink ./lib/napi-v7 failed:  null
npm WARN my-electron-app@1.0.0 No description
npm WARN my-electron-app@1.0.0 No repository field.

+ @tensorflow/tfjs-node@3.0.0
added 107 packages from 65 contributors and audited 200 packages in 49.2s

11 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

PS C:\Users\lfernandes\folder_sorter\my-electron-app> rm .\node_modules\@tensorflow\tfjs-node\deps\lib\tensorflow.dll   

@rthadur
Copy link
Contributor

rthadur commented Feb 3, 2021

I guess this is something to do with electron app , can you please check a similar issue here #2640 , thank you

@LPugens
Copy link
Author

LPugens commented Feb 4, 2021

Thanks! I managed to make it work with he info in the issue you linked.

After some research, I found out that the node version used to install the node packages (such as tfjs) should be the exact one bundled with electron. Mainly because of the napi version.
As seen on the release blog post, the current electron version (11.0.0) has to be paired with node version 12.18.3.
After this simple fix, and reinstalling the packages, the app is working fine. I just wish it was better documented for newcomers in the electron project.

Thanks again @rthadur!

@LPugens LPugens closed this as completed Feb 4, 2021
@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@Diabl0269
Copy link

There is underlying issue with windows , you need to manually copy files from deps/lib to node_modules/@tensorflow/tfjs-node/lib/napi-v7.

I am having getting the same error described in this post, only that I am not using electron.
I get the symlink ./lib/napi-v7 failed: null error when trying to install the package.
I want to check this solution but I don't understand where is the 'deps/lib' folder should be located.

@LPugens
Copy link
Author

LPugens commented Feb 28, 2021

@Diabl0269 The deps folder of the package is located at .\node_modules\@tensorflow\tfjs-node\deps for local installations.

@Diabl0269
Copy link

Diabl0269 commented Feb 28, 2021

@Diabl0269 The deps folder of the package is located at .\node_modules\@tensorflow\tfjs-node\deps for local installations.

Thanks.

In my case I haven't been able to install the package so I guess this a different issue, which I already asked about in a new thread.
#4761

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

3 participants