Search code examples
tensorflownode-gyptensorflow.js

How to use tfjs-node with libtensorflow that is built from source


I see that it is possible to use libtensorflow that is built from source, as mentioned in the README https://github.com/tensorflow/tfjs-node#optional-build-libtensorflow-from-tensorflow-source

I have successfully built from source, but I don't know how to let tfjs-node use this custom built version, instead of the pre-built one.


Solution

  • I found that the following workaround seems to work:

    Copy the file bazel-bin/tensorflow/libtensorflow.so from the tensorflow source directory to replace node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so inside your project.

    Hopefully there is a better way to do npm install such that there is no need to download the pre-compiled version.