Skip to content

I'm running code of tensorflow/tfjs-node-gpu or tensorflow/tfjs-node after installation. I got an error. #8215

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

Closed
satendra-cotginanalytics opened this issue Mar 21, 2024 · 7 comments

Comments

@satendra-cotginanalytics
Copy link

satendra-cotginanalytics commented Mar 21, 2024

This template is for miscellaneous issues not covered by the other issue categories.
My node version is 20

`node:internal/modules/cjs/loader:1473
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified module could not be found.
\?\D:\nodedsa\faceapi\node_modules@tensorflow\tfjs-node-gpu\lib\napi-v8\tfjs_binding.node
at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object. (D:\nodedsa\faceapi\node_modules@tensorflow\tfjs-node-gpu\dist\index.js:72:16)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12) {
code: 'ERR_DLOPEN_FAILED'
}
`

@gaikwadrahul8
Copy link
Contributor

Hi, @satendra-cotginanalytics

Thank you for bringing this issue to our attention and I would suggest you to please follow below steps with Node v19.9.0 and different Python versions like 3.6, 3.7, 3.8, 3.9,3.10 or 3.11, if it did not work then please try with this specific versions Node v18.16.1, Pyhton 3.9.13, node-gyp 10.0.1, npm 9.5.1 and it should work

  • Step 1-: Create new folder and move to that folder by using cd folder_name then run command npm init -y it will create empty Node.js project
  • Step 2-: npm install -g node-gyp Or sudo npm install -g node-gyp
  • Step 3-: Download the Visual Studio Build Tools and select the Desktop development C++ (keep it default settings option)
  • Step 4 -: node-gyp configure --msvs_version=2017 Or sudo node-gyp configure --msvs_version=2017 (run this command and replace --msvs_version value with your downloaded Visual Studio build tool version)
  • Step 5-: set npm_config_python="C:\path\to\python.exe" Or sudo set npm_config_python="C:\path\to\python.exe(Replace your python.exe path in double quotes )
  • Step 6-: go to your project directory and try to install (npm install @tensorflow/tfjs-node Or sudo npm install @tensorflow/tfjs-node)

tfjs-node requires AVX processors and tfjs-node library uses AVX instructions to improve the performance of its operations. If your CPU does not support AVX, as far I know you will not be able to use tfjs-node if I'm not wrong so to check AVX support please follow below steps

  • Right-click on the Start button and select "System Information."
  • Expand the "Processor" category in the left-hand pane.
  • Look for "Instruction Set" or "Extended Instructions" in the right-hand pane. If AVX is supported, you should see it listed there (e.g., "AVX2").

I tried from my end and tfjs-node installing successfully and I ran sample model training code and it's working as expected, for your reference I have added output log below :

PS C:\Users\gaikwadrahul\Desktop\test-8202> node -v
v19.9.0
PS C:\Users\gaikwadrahul\Desktop\test-8202> npm -v
9.6.3
PS C:\Users\gaikwadrahul\Desktop\test-8202> python
Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
PS C:\Users\gaikwadrahul\Desktop\test-8202> npm init -y
PS C:\Users\gaikwadrahul\Desktop\test-8202> npm install -g node-gyp

changed 101 packages in 12s
PS C:\Users\gaikwadrahul\Desktop\test-8202> npm install @tensorflow/tfjs-node

up to date, audited 122 packages in 1s

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

found 0 vulnerabilities
PS C:\Users\gaikwadrahul\Desktop\test-8202> node .\index.js
2024-03-18 12:04:54.474812: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Epoch 1 / 10
eta=0.0 ==================================================================================>
3073ms 307us/step - MAE=0.327 loss=0.166 val_MAE=0.303 val_loss=0.138
Epoch 2 / 10
eta=0.0 ==================================================================================>
2017ms 202us/step - MAE=0.277 loss=0.110 val_MAE=0.259 val_loss=0.0947
Epoch 3 / 10
eta=0.0 ==================================================================================>
2126ms 213us/step - MAE=0.261 loss=0.0944 val_MAE=0.252 val_loss=0.0883
Epoch 4 / 10
eta=0.0 ==================================================================================>
2123ms 212us/step - MAE=0.253 loss=0.0875 val_MAE=0.247 val_loss=0.0837
Epoch 5 / 10
eta=0.0 ==================================================================================>
1960ms 196us/step - MAE=0.250 loss=0.0851 val_MAE=0.243 val_loss=0.0803
Epoch 6 / 10
eta=0.0 ==================================================================================>
2440ms 244us/step - MAE=0.250 loss=0.0847 val_MAE=0.244 val_loss=0.0814
Epoch 7 / 10
eta=0.0 ==================================================================================>
1754ms 175us/step - MAE=0.249 loss=0.0843 val_MAE=0.296 val_loss=0.131
Epoch 8 / 10
eta=0.0 ==================================================================================>
2062ms 206us/step - MAE=0.248 loss=0.0838 val_MAE=0.242 val_loss=0.0793
Epoch 9 / 10
eta=0.0 ==================================================================================>
1721ms 172us/step - MAE=0.249 loss=0.0841 val_MAE=0.242 val_loss=0.0792
Epoch 10 / 10
eta=0.0 ==================================================================================>
1703ms 170us/step - MAE=0.248 loss=0.0837 val_MAE=0.246 val_loss=0.0825
PS C:\Users\gaikwadrahul\Desktop\test-8202> 

Thank you for your understanding and patience.

@gaikwadrahul8
Copy link
Contributor

Hi, @satendra-cotginanalytics

To confirm, were you able to successfully install tfjs-node on your Windows system by following the provided instructions and workaround? If the installation was successful and able to run your code without any errors , please feel free to close this issue.

If you're still encountering problems, please provide us with a new error log and your code snippet after attempting the instructions and workaround. This will help us investigate the issue further on our end.

Thank you for your cooperation and patience in resolving this matter.

@satendra-cotginanalytics
Copy link
Author

Yes all issues resolved.

Thanks.👍❤️❤️

Copy link

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

@ZhuBoao
Copy link

ZhuBoao commented May 21, 2024

This is so silly. In order to use this package I have to lock my Node.js version to 3 years ago. No wonder people move to pytorch.

@PrinOrange
Copy link

I also hit this bug at 2025 : (

Plantform: Windows 11 x64
Node: v22.14.0
@tensorflow/tfjs-node: "^4.22.0"
pnpm: 10.11.0

When loading the tensorflow, it trigged the error

PS E:\frontend-projects\dog-vs-cat> pnpm run start

> [email protected] start E:\frontend-projects\dog-vs-cat
> tsx main.ts

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

Error: The specified module could not be found.
\\?\E:\frontend-projects\dog-vs-cat\node_modules\.pnpm\@[email protected][email protected]\node_modules\@tensorflow\tfjs-node\lib\napi-v9\tfjs_binding.node

I have referred the solution that mentioned above, but it does not work with still same error.

@PrinOrange
Copy link

I think this pull request #8547 would be help better.
For node.js v22 it requires napi-v9.
Considering merge it, please. Thanks.

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

4 participants