The @tensorflow/tfjs-node repo supports npm package @tensorflow/tfjs-node and @tensorflow/tfjs-node-gpu on Windows/Mac/Linux. This guide lists commands to use when developing this package.
$ yarn
This command installs all dependencies and devDependencies listed in package.json. It also downloads the TensorFlow C library and native node addon.
$ yarn build-addon-from-source
This command will compile a new native node addon from source files.
$ yarn install-from-source
This command does the following:
- Clears local binary and addon resources
- Downloads the TensorFlow C library
- Compiles the native addon from source files (instead of downloading pre-compile addon)
$ yarn enable-gpu
This command is the same as yarn install-from-source
except it uses the TensorFlow GPU library.
$ yarn build
$ yarn publish-local
This command packs the tfjs-node
package and publishes locally through yalc.
NOTE: Dependent packages must install this locally published package through yalc and compile the node native addon locally. In the dependent package run the following command to link local published tfjs-node
package:
$ yalc link @tensorflow/tfjs-node
$ cd .yalc/@tensorflow/tfjs-node
$ yarn && yarn build-addon-from-source
$ cd ../../..
$ yarn test
Publishing this package requires uploading objects to GCP bucket. Developers need to install GCP command line tool gsutil before publishing. Please ask TFJS developers for GCP project ID.
$ yarn build-and-upload-addon publish
This command will compile, compress, and upload a new node addon to GCP bucket. Please read build-and-upload-addon.sh for details.
$ yarn build-npm
This command will build a new version of tfjs-node/tfjs-node-gpu NPM tarball. NOTE: this command does not update the pre-compiled node addon to GCP (see yarn build-and-upload-addon publish
).
$ yarn publish-npm
This command compiles a new node addon, upload it to GCP, then builds and publishes a new npm package. Please read instruction in publish-npm.sh before publishing.
$ yarn upload-windows-addon
Most times the NPM package is published on Linux machine, and only the Linux node addon is compiled and uploaded to GCP bucket. To build and upload the native node addon for Windows, developers should run the above commands on Windows machine. Please read build-and-upload-windows-addon.bat for details.
Some platforms need a custom version of libtensorflow built for them because tensorflow does not host binaries for them. Right now, the only automated platform is linux-arm64, which can be built with the following command:
gcloud builds submit . --config=scripts/build-libtensorflow-arm64.yml