Easy way to install TensorFlow(tfjs-node) in Windows 11 machine
In this article, I am explaining about an easy way to install TensorFlow.js(tfjs-node) on a Windows 11 machine. Why am I writing this when installation instructions are already available on the TensorFlow.js website? I came across a few errors when running ‘npm install’ command. It was not easy to determine what is missing from looking at the error descriptions.
What is tfjs-node?
It is a Node.js addon for TensorFlow which leverages the power of TensorFlow C binary and the hardware acceleration features of your CPU. What is a Node.js addon? Addons are a type of Node.js modules which are written in C/C++ and can be used in node by using require() statements as shown in figure 1.
What are the requirements for compiling and installing tfjs-node?
The requirements are as shown in figure 2 below.
What are the steps to compile and install tfjs-node?
- Install python if not available
2. Edit the path user or system variable; ensure that the path to python is added to the ‘path’ variable.
3. Install Visual Studio community edition with desktop development with C++
4. Install visual studio build tools
5. Ensure that node-gyp is available: npm install -g node-gyp
6. Install tfjs-node: npm install @tensorflow/tfjs-node
When building the tfjs-node for your machine. Node-gyp will automatically find these things for you:
- Visual Studio instance available
- MSBuild.exe if available
- Python
In the end, I think sharing this will remove a lot of guess work for other developers looking to work with TensorFlow.js in Windows machines. Thanks for reading.