question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tensorflow.dll is missing from tfjs-node and I can't build it following the instructions

See original GitHub issue

I’ve tried just about every potential fix I could find on mitigating this issue from this very own GitHub Repo and other sources. I’m going to apologize upfront, because I plan on detailing all the results here.

OS: Windows 10 Enterprise (OS Build 19042.572) CPU: Intel® Core™ i7-7500U CPU @ 2.70GHz 2.90 GHz Node: v14.15.1 npm: v6.14.5 python: v2.7 node-gyp: @7.1.2 Tensorflow: @tensorflow/tfjs-node": “^2.7.0”

The origin of the issue is as follows:

  • Removed the entirety of node_modules from the project
  • Deleted package-lock.json
  • npm install
  • Creating a main.ts which has the following:
import * as tf from '@tensorflow/tfjs-node';

async function get_model() {
  const model = tf.sequential();
  model.add(tf.layers.dense({ inputShape: [7], units: 124, activation: 'relu', kernelInitializer: 'leCunNormal' }));
  model.add(tf.layers.dense({ units: 64, activation: 'relu' }));
  model.add(tf.layers.dense({ units: 32, activation: 'relu' }));
  model.add(tf.layers.dense({ units: 1, activation: "sigmoid" }));
  model.summary();
  return model;
}
get_model();
  • tsc
  • running the main.ts, produces
Error: The specified module could not be found.
\\?\c:\workspace\my_project\node_modules\@tensorflow\tfjs-node\lib\napi-v6\tfjs_binding.node

When I peek into that directory "c:\workspace\my_project\node_modules@tensorflow\tfjs-node\lib\napi-v6" I notice the .dll that should be created is missing.

At this point, I should note that this project WAS WORKING up until I did a recent windows update, node version update, and I changed the version of Tensorflow in package.json from ‘^1.3.2’ to ‘^2.7.0’.

Separately, I do have a working tfjs-examples/baseball-node project that I built before the windows update. The contents of its tfjs-node directory (C:\workspace\ml_examples\tfjs-examples\baseball-node\node_modules@tensorflow\tfjs-node\lib\napi-v5) DOES have a tensorflow.dll. Its package.json has: “@tensorflow/tfjs-node”: “^1.3.2”

The difference between napi-v5 and napi-v6 hasn’t escaped me, but I’m a novice when it comes to compiling these c++ libraries to js.

Now, back to my project.

I then tried doing the suggested instructions from other issues.

First, I navigate into “c:\workspace\my_project\node_modules@tensorflow\tfjs-node” and run

npm install --build-from-source

It runs but no .dll is created. Not sure if the following means anything

> core-js@3.7.0 postinstall C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Next, from the same “c:\workspace\my_project\node_modules@tensorflow\tfjs-node” dir, I try,

npm run build-addon-from-source  

which produces

> @tensorflow/tfjs-node@2.7.0 build-addon-from-source C:\workspace\my_project\node_modules\@tensorflow\tfjs-node
> node-pre-gyp install --build-from-source

node-pre-gyp WARN Using needle for node-pre-gyp https download 
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  tfjs_backend.cc
  tfjs_binding.cc
  win_delay_load_hook.cc
     Creating library C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build\Release\tfjs_binding.lib and object C:\workspace\my_project\nod
  e_modules\@tensorflow\tfjs-node\build\Release\tfjs_binding.exp
  tfjs_binding.vcxproj -> C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build\Release\\tfjs_binding.node
  tfjs_binding.vcxproj -> C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build\Release\tfjs_binding.pdb (Full PDB)
  Copying C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build\Release\/tfjs_binding.node to C:/workspace/my_project/node_modules/@tensorf
  low/tfjs-node/lib/napi-v6\tfjs_binding.node
          1 file(s) copied.

Yet, no .dll is created. And same issue as above happens when I try to run:

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

Per the WINDOWS_TROUBLESHOOTING.md readme, I’ve run

node-gyp configure --verbose

Which does appear to have an issue and thus me creating this issue.

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'configure',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using node-gyp@7.1.2
gyp info using node@14.15.1 | win32 | x64
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python checking Python explicitly set from environment variable PYTHON
gyp verb find Python - process.env.PYTHON is "C:\Python27\python.exe"
gyp verb find Python - executing "C:\Python27\python.exe" to get executable path
gyp verb find Python - "C:\Python27\python.exe" is not in PATH or produced an error
gyp verb find Python checking if "python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - "python3" is not in PATH or produced an error
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:\Program Files (x86)\Python27\python.exe"
gyp verb find Python - executing "C:\Program Files (x86)\Python27\python.exe" to get version
gyp verb find Python - version is "2.7.0"
gyp info find Python using Python version 2.7.0 found at "C:\Program Files (x86)\Python27\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 14.15.1
gyp verb command install [ '14.15.1' ]
gyp verb install input version string "14.15.1"
gyp verb install installing version: 14.15.1
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: 14.15.1
gyp verb build dir attempting to create "build" dir: C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build
gyp verb build dir "build" dir needed to be created? C:\workspace\my_project\node_modules\@tensorflow\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.1300) found at:
gyp verb find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
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.17763.0
gyp info find VS using VS2017 (15.9.28307.1300) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
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:\workspace\my_project\node_modules\@tensorflow\tfjs-node\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\config.gypi
gyp verb common.gypi checking for gypi file: C:\workspace\my_project\node_modules\@tensorflow\tfjs-node\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Program Files (x86)\Python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\me\\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:\\workspace\\my_project\\node_modules\\@tensorflow\\tfjs-node\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\me\\AppData\\Local\\node-gyp\\Cache\\14.15.1\\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\\me\\AppData\\Local\\node-gyp\\Cache\\14.15.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\me\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\14.15.1\\\\<(target_arch)\\\\node.lib',  
gyp info spawn args   '-Dmodule_root_dir=C:\\workspace\\my_project\\node_modules\\@tensorflow\\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:\\workspace\\my_project\\node_modules\\@tensorflow\\tfjs-node\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
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\me\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:277:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\me\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--verbose"
gyp ERR! cwd C:\workspace\my_project\node_modules\@tensorflow\tfjs-node
gyp ERR! node -v v14.15.1
gyp ERR! node-gyp -v v7.1.2
gyp ERR! not ok

All of the above have been run from Adminstrative Powershell so I don’t suspect any permissions issues.

In the interest of keeping this “short”. I’ve also downloaded tfjs into its own project and followed all the steps above. which more or less produce the same issue. No .dll is being created (I think is the real issue).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
quickdrawmcballscommented, Nov 18, 2020

So it appears that this previous issue #2619 has a potential workaround. the built .dll can be found in the deps/lib. I moved into lib dir and it worked.

In the lib/napi-v4 folder, it should have tfjs_binding.node file and tensorflow.dll file. tensorflow.dll file is moved from deps/lib folder during installation. So it seems like the installation script failed to move it. Can you fork this repo, then go to tfjs-node folder and run npm install or yarn? Then paste the installation script and what is inside lib\napi-v4 folder?

0reactions
quickdrawmcballscommented, Nov 23, 2020

@pyu10055, for what its worth, I’m on win64. And last I checked over the weekend, this is still broke.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"tfjs_binding.node" not found in @tensorflow installed folder
So create simple project and install latest version of @tensorflow/tfjs-node. Find Tensorflow.dll file in node_modules at given path for ex.
Read more >
@tensorflow/tfjs - npm
TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models. Develop ML in ...
Read more >
tfjs-node-grid-search - npm Package Health Analysis - Snyk
tfjs-node -grid-search (TNGS) is a grid search utility for TensorFLow.js in Node.js. Simply define ranges of hyperparameters.
Read more >
Environments for running AI in Node.js - IBM Developer
Run yarn or npm install to trigger the download and build procedures from the @tensorflow/tfjs-node-gpu npm folder. The following code is an ...
Read more >
Facing Issue While Installing Tensorflow.Js Via Npm - ADocLib
I am unable to install @tensorflow/tfjsnode. I'd appreciate it if someone can shed some light and let me know what I'm missing. I'm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found