Tfjs: Initialization of backend tensorflow failed Error: The specified module could not be found.

Created on 22 May 2019  路  10Comments  路  Source: tensorflow/tfjs

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

           "@tensorflow/tfjs-node-gpu": "^1.1.2"

Browser version

             N?A

Describe the problem or feature request

                error when initializing index.js  
        Initialization of backend tensorflow failed

Error: The specified module could not be found.
\?\C:\video_object_detector\node_modules\@tensorflow\tfjs-node-gpu\build\Release\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:800:18)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at bindings (C:\video_object_detector\node_modules\bindings\bindings.js:84:48)
at Object.factory (C:\video_object_detector\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:48:60)
at Engine.initializeBackend (C:\video_object_detector\node_modules\@tensorflow\tfjs-core\dist\engine.js:237:48)
at Engine. (C:\video_object_detector\node_modules\@tensorflow\tfjs-core\dist\engine.js:200:35)
at step (C:\video_object_detector\node_modules\@tensorflow\tfjs-core\dist\engine.js:48:23)

Code to reproduce the bug / link to feature request

npm install -g rollup
npm install g node-gyp
npm install @tensorflow/tfjs-node-gpu
node-gyp configure --verbose
npm --add-python-to-path='true' --debug install --global windows-build-tools

windows 10 Home single language v 1803
GEFORCE GTX 950M
Cuda 9.0 with cudnn 7.5.0.56
Python 2.7.16

awaiting response support

All 10 comments

@davidsoergel can you please help me address this issue

I currently have the same exact issue, but weirdly enough it still works. Not only that but it runs faster than the regular version even though it shows this error before running. I got about a 4-5x speed increase compared to using @tensorflow/tfjs-node. Not sure if it is actually using the gpu though. When I look at my task manager I still see the same spike in cpu usage as shown when running the non-gpu version and no spike in gpu usage. I am running in the same environment as @billTeston just with a RTX 2070. @davidsoergel Any help would be very much appreciated.

@billTeston @samfultonschool
I had the same issue as you, using CUDA 10.1.
I took a look at the dll files the node process tried to load when loading the native node package, and found that it tried to load cublas64_100.dll instead of cublas64_101.dll for CUDA 10.1.

I installed CUDA 10.0 from https://developer.nvidia.com/cuda-10.0-download-archive and now it works without problems for me.

Have a nice day :)

@Turtlefight
I have currently the same issue (Cuda 10.2.120 and "@tensorflow/tfjs-node-gpu": "^1.2.3")
Where did you see that the node process tried to load cublas64_xxx.dll ?

Once I have that information, I could install the corresponding version of Cuda

@CharlesCousyn I used Process Monitor from Sysinternals
If you filter for only the node process, you can see the files it is opening (including the dlls it loads / tries to load).

However it seems like Tensorflow only supports CUDA 10.0 (see Software Requirements ).
I also didn't notice this, the error message it gives is pretty cryptic ;)

Have a nice day :)

I'm running into the same issue on a windows machine.

Running:

nvcc --version

Produces:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:04_Central_Daylight_Time_2018
Cuda compilation tools, release 10.0, V10.0.130

I can install tfjs-node-gpu successfully with `npm install @tensorflow/tfjs-node-gpu

I've also made sure ahead of time that python 2.7 is installed. Running python -v produces:
C:\Python27\lib\encodings\cp1252.pyc matches C:\Python27\lib\encodings\cp1252.py
import encodings.cp1252 # precompiled from C:\Python27\lib\encodings\cp1252.pyc
Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32

When I run my program:
node index.js

I get an error:

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

Error: The specified module could not be found.
\?\C:\Users\Al\Source\pose-extraction\node_modules\@tensorflow\tfjs-node-gpu\lib\napi-v4\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:805:18)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:\Users\Al\Source\pose-extraction\node_modules\@tensorflow\tfjs-node-gpu\dist\index.js:44:16)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)

Just to make sure, I ran the below command successfully:

npm --add-python-to-path='true' --debug install --global windows-build-tools

I've then followed the instruction on running node-gyp configure --verbose and get an error:

node-gyp configure --verbose
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\Program Files\nodejs\node.exe',
gyp verb cli 'C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js',
gyp verb cli 'configure',
gyp verb cli '--verbose' ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - executable path is "C:\Users\Al.windows-build-tools\python27\python.exe"
gyp verb find Python - executing "C:\Users\Al.windows-build-tools\python27\python.exe" to get version
gyp verb find Python - version is "2.7.15"
gyp info find Python using Python version 2.7.15 found at "C:\Users\Al.windows-build-tools\python27\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 10.16.0
gyp verb command install [ '10.16.0' ]
gyp verb install input version string "10.16.0"
gyp verb install installing version: 10.16.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 10.16.0
gyp verb build dir attempting to create "build" dir: C:\Users\Al\Source\tfjs-node\build
gyp verb build dir "build" dir needed to be created? C:\Users\Al\Source\tfjs-node\build
gyp verb find VS msvs_version not set from command line or npm config
gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp verb find VS checking VS2017 (15.9.28307.665) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v141
gyp verb find VS - found Windows SDK: 10.0.16299.0
gyp info find VS using VS2017 (15.9.28307.665) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
gyp info find VS run with --verbose for detailed information
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: C:\Users\Al\Source\tfjs-node\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\Users\Al\Source\tfjs-node\config.gypi
gyp verb common.gypi checking for gypi file: C:\Users\Al\Source\tfjs-node\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Users\Al.windows-build-tools\python27\python.exe
gyp info spawn args [ 'C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp\gyp\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Al\Source\tfjs-node\build\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\Users\Al\AppData\Local\node-gyp\Cache\10.16.0\include\node\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\Users\Al\AppData\Local\node-gyp\Cache\10.16.0',
gyp info spawn args '-Dnode_gyp_dir=C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\Users\Al\AppData\Local\node-gyp\Cache\10.16.0\<(target_arch)\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\Users\Al\Source\tfjs-node',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\Users\Al\Source\tfjs-node\build',
gyp info spawn args '-Goutput_dir=.' ]
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:344:16)
gyp ERR! stack at ChildProcess.emit (events.js:198:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Al\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--verbose"
gyp ERR! cwd C:\Users\Al\Source\tfjs-node
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok

In my case it turns out cudnn was not installed! smh! I followed the instructions here:
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installwindows

And now it works for me :)

@oveddan thank you , @billTeston could you check above steps let us know if it is working ?

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

In my case it turns out cudnn was not installed! smh! I followed the instructions here:
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html#installwindows

And now it works for me :)

Yes! Installing cuDNN was the fix for this for me. YAY!
Thanks so much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lastnod picture lastnod  路  3Comments

kylemcdonald picture kylemcdonald  路  3Comments

JasonShin picture JasonShin  路  4Comments

beele picture beele  路  3Comments

chrisdonahue picture chrisdonahue  路  3Comments