Closed nickplee closed 2 years ago
@nickplee thank you for reporting this, can you help to test it out following the instruction of custom TF build https://github.com/tensorflow/tfjs/tree/master/tfjs-node#optional-build-optimal-tensorflow-from-source
@yhwang any suggestions on this? thanks.
since the tfjs-node@2.8.3 is using tensorflow shared libs v1.15.0, I think it's better to build the dependent shared libs by using the link @pyu10055 posted above. However, the tricky part would be tweaking the tensorflow to build on darwin arm64. It's okay by using ubuntu with arm64 to build tensorflow shared libs. But I am not sure about darwin with arm64.
For the tensorflow apple provides, you can verify whether you can find all files in this tarball from the binaries that apple provides. If yes, you can just put them under node_modules/@tensorflow/tfjs-node/lib/deps
where you install the tfjs-node npm package. Then you can run npm run build-addon-from-source
under node_modules/@tensorflow/tfjs-node
. It will build the node binding for you. If everything goes well, you can try to use tfjs-node
. Again, seems apple provides newer version then 1.15.0, I don't know if you can run tfjs-node without any issue even you can build the node binding successfully.
@pyu10055 a side question: any idea of supporting more platforms and architectures officially?
@yhwang @pyu10055
I actually already tried subbing in the Apple library and recompiling the binding. Once you install it, it includes the dylib as well as the headers.
I was hopeful, but ran in to two issues:
TF_StringDecode
, TF_StringEncode
, and TF_StringEncodedSize
are used by the binding and were deprecated/removed from the TensorFlow C API in 2.4.0@yhwang It would definitely be useful to official support other platforms officially, but no plan as this moment, might be a good project for the SIG, any suggestions are welcome.
@nickplee Do you mind contriubting your fix attempt as an PR?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
Perhaps with https://github.com/tensorflow/tensorflow/pull/45404 this is more feasible? Has anyone been able to get tfjs-node to work on an M1 device?
We're extremely interested in this as well. If anyone has been able to get it working, we would very, very much appreciate some pointers :)
Closing as stale. Please @mention us if this needs more attention.
Can this be reopened or someone point us in the direction of where we should go to help? Support for the new M1 macs is essential for any applications running edge TF models.
@patrickhulce reopened
Thank you @rthadur! Is there anything that we can help with? My current understanding based on https://github.com/tensorflow/tfjs/issues/4514#issuecomment-758334433 is that there a few patches (possibly that @nickplee already has written?) to work with the 2.4 API or attempt to rebuild 2.3 using the methods described in https://github.com/tensorflow/tensorflow/pull/45404.
My M1 rig is arriving this week, so I'll be able to provide more hands-on assistance then if I know where I can be helpful :)
Gentle ping for @pyu10055
Just chiming in - I wasn't able to get tfjs/node working on my M1. The moment I import '@tensorflow/tfjs-node', node just quits out with no error message.
Any update on this issue by any chance? Experiencing the exact same dylib error.
I've just successfully built and ran my models with tfjs-node 3.5.0 with TensorFlow 2.5.0-rc1 on my M1 Macbook Air. From what I could see, the yet-to-be released TF 2.5.0 is where Apple Silicon is supported, but pre-release 2.5.0-rc1 is already fully usable.
Caveat: I didn't keep exact track of all the steps, this was written in "hindsight" so I maybe I'm missing something.
# 1) set the build directory at will and clone Tensorflow
export BUILDDIR=~/tf-build
mkdir $BUILDDIR && cd $BUILDDIR
git clone -b v2.5.0-rc1 https://github.com/tensorflow/tensorflow tensorflow
cd tensorflow
# 2) you'll need Bazel 3.7.2 to build TF from source
# I've used bazelisk installed with brew under Rosetta
# note that the binaries are built for ARM64 regardless
arch -x86_64 bash
brew install bazelisk
# 3) the following takes a couple hours aprox on my Macbook air
# set the number of jobs to a higher value to speed up the build
# or lower to have it in the background
USE_BAZEL_VERSION=3.7.2 bazel build --jobs 4 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow.dylib
USE_BAZEL_VERSION=3.7.2 bazel build --jobs 4 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow_framework.dylib
# 4) now install/bind JS libs with NPM
# I'm assuming you have NVM to manage Node versions
# brew install nvm if you don't have it yet
exit # <---------- we leave the Rosetta bash prompt here
cd $BUILDDIR
mkdir tfjs-test && cd tfjs-test
nvm install 16 # <---- I've actually built with 15.8.0, but it's working under v16 too
npm init -y
npm i node-pre-gyp
npm i @tensorflow/tfjs-node@latest --ignore-scripts
cd node_modules/@tensorflow/tfjs-node/
mkdir -p deps/lib deps/include/tensorflow
cp -r $BUILDDIR/tensorflow/tensorflow/c deps/include/tensorflow/
cp -r $BUILDDIR/tensorflow/tensorflow/core deps/include/tensorflow/
cp -r $BUILDDIR/tensorflow/bazel-bin/tensorflow/*.dylib deps/lib/
npx node-pre-gyp rebuild
That's it.
You should be able to import/require the Tensorflow JS modules and train/predict without issues. I'm still testing this, but so far so good. Training speed is ~5x or faster compared my 2015 Intel i7 Macbook Air and 2-3x compared to a 16 core 4GHz Intel Xeon E5 server.
You can install the @tensorflow/tfjs-node directory by copying it around, repeating the steps or just doing this in a global context (-g
, not recommended).
Thank you @rodrigolive , @patrickhulce @nickplee can you please confirm if this is resolved on M1 chip with latest release.
The issue as described is not resolved with @rodrigolive's workaround. Manually hacking @tensorflow/tfjs-node
to compile has been workable since https://github.com/tensorflow/tensorflow/pull/45404. Could this issue track working by default? i.e. the @tensorflow/tfjs-node/scripts/install.js
script should not throw a fatal error when run on M1, it should download an arm64 compatible binary instead :)
I might be able to take some time next weekend to give a stab at it if no one else has the bandwidth to do so, but closing would be unfortunate as there's still work to be done in this repo.
Note that I've used a release candidate version. I'd say we still need to wait for TensorFlow 2.5.x to be released, that would be the first GA version to fully support Apple Silicon. Then, yes, we can publish the binary to the storage location and update the install scripts to handle darwin-arm64
. As I understand from the Release Notes for 2.5.0-rc1
, apparently there aren't any breaking changes that would affect TFJS.
I'm also not sure about the build flags that should be used, --config=macos_arm64
seems to fold the correct configuration options. Here are some build configs in case they actually enable M1 features that could improve performance to make sure we publish a fully optimized M1 lib.
--config=mkl # Build with MKL support.
--config=mkl_aarch64 # Build with oneDNN support for Aarch64.
--config=monolithic # Config for mostly static monolithic build.
--config=numa # Build with NUMA support.
--config=dynamic_kernels # (Experimental) Build kernels into separate shared objects.
--config=v2 # Build TensorFlow 2.x instead of 1.x.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
@tensorflow-butler please do not close, it is awaiting 2.5.0 release to be completed, but still important.
Has there been any progress on this? any fixes recently?
https://github.com/tensorflow/tensorflow/releases/tag/v2.5.0 released 3 days ago.
@all can you please confirm if this is resolved after 2.5 release ? Thank you
Not working for me yet, but that is probably due to my own incompetence. Will try some other things after work today. If anyone finds a step by step way please share.
On Mon, May 17, 2021 at 11:23 AM Rajeshwar Reddy T @.***> wrote:
@ALL https://github.com/ALL can you please confirm if this is resolved after 2.5 release ? Thank you
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/4514#issuecomment-842459788, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDJPC75TWVPMWGMTLTK5CLTOE7IHANCNFSM4V3HOZSQ .
I basically followed what @rodrigolive mentioned above cloning this time the v2.5.0 tag. Tensorflow built based on Bazel 4.1.0 rc4, bazel version I built on ARM- and tested this rebuilt tfjs-node
dependency with danfo.js, it works.
So when I run the command: npm install --save @tensorflow/tfjs-node
I get this giant error
@.: Please upgrade to @mapbox/node-pre-gyp: the
non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped
package will recieve updates in the future
npm ERR! code 1
npm ERR! path /Users/devintripp/Desktop/Current
@./tfjs-node
npm ERR! command failed
npm ERR! command sh -c node scripts/install.js
npm ERR! CPU-darwin-3.6.1.tar.gz
npm ERR! node-pre-gyp install failed with error: Error: Command failed:
node-pre-gyp install --fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using @.
npm ERR! node-pre-gyp info using @. | darwin | x64
npm ERR! node-pre-gyp WARN Using request for node-pre-gyp https download
npm ERR! node-pre-gyp info check checked for
"/Users/devintripp/Desktop/Current
@./tfjs-node/lib/napi-v8/tfjs_binding.node"
(not found)
npm ERR! node-pre-gyp http GET
https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.6.1/CPU-darwin-3.6.1.tar.gz
npm ERR! node-pre-gyp http 404
https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.6.1/CPU-darwin-3.6.1.tar.gz
npm ERR! node-pre-gyp WARN Tried to download(404):
https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.6.1/CPU-darwin-3.6.1.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not found for
@@. and @. (node-v83 ABI, unknown)
(falling back to source compile with node-gyp)
npm ERR! node-pre-gyp http 404 status code downloading tarball
https://storage.googleapis.com/tf-builds/pre-built-binary/napi-v8/3.6.1/CPU-darwin-3.6.1.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using @.
npm ERR! gyp info using @. | darwin | x64
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using @.
npm ERR! gyp info using @. | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.8 found at
"/Users/devintripp/miniforge3/envs/tf/bin/python3"
npm ERR! gyp info spawn /Users/devintripp/miniforge3/envs/tf/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args
'/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/devintripp/Desktop/Current
@./tfjs-node/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args
'/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args
'/Users/devintripp/Library/Caches/node-gyp/14.17.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args
'-Dnode_root_dir=/Users/devintripp/Library/Caches/node-gyp/14.17.0',
npm ERR! gyp info spawn args
'-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args
'-Dnode_lib_file=/Users/devintripp/Library/Caches/node-gyp/14.17.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args
'-Dmodule_root_dir=/Users/devintripp/Desktop/Current
@./tfjs-node',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using @.
npm ERR! gyp info using @. | darwin | x64
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! clang: error: no such file or directory:
@./tfjs-node/deps/include'
npm ERR! make: [Release/obj.target/tfjs_binding/binding/tfjs_backend.o]
Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make
failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit
(/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:376:20)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:277:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command "/usr/local/bin/node"
"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
"build" "--fallback-to-build" "--module=/Users/devintripp/Desktop/Current
@./tfjs-node/lib/napi-v8/tfjs_binding.node"
"--module_name=tfjs_binding"
"--module_path=/Users/devintripp/Desktop/Current
@./tfjs-node/lib/napi-v8"
"--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=8"
"--node_napi_label=napi-v8"
npm ERR! gyp ERR! cwd /Users/devintripp/Desktop/Current
@./tfjs-node
npm ERR! gyp ERR! node -v v14.17.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error
npm ERR! node-pre-gyp ERR! stack Error: Failed to execute
'/usr/local/bin/node
/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build
--fallback-to-build --module=/Users/devintripp/Desktop/Current
@./tfjs-node/lib/napi-v8/tfjs_binding.node
--module_name=tfjs_binding --module_path=/Users/devintripp/Desktop/Current
@./tfjs-node/lib/napi-v8
--napi_version=8 --node_abi_napi=napi --napi_build_version=8
--node_napi_label=napi-v8' (1)
npm ERR! node-pre-gyp ERR! stack at ChildProcess.
npm ERR! A complete log of this run can be found in: npm ERR! /Users/devintripp/.npm/_logs/2021-05-18T01_28_12_433Z-debug.log
I have been able to install it before but it still didn't work so I restarted the installation process and I can't even get past this point now.
On Mon, May 17, 2021 at 5:17 PM Damien @.***> wrote:
I basically followed what @rodrigolive https://github.com/rodrigolive mentioned above cloning this time the v2.5.0 tag. Tensorflow built based on Bazel 4.1.0 rc4, bazel version I built on ARM- and tested this rebuilt tfjs-node dependency with danfo.js, it works.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/tfjs/issues/4514#issuecomment-842678252, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANDJPC6M6GEJAZZ32OC3MXDTOGIZBANCNFSM4V3HOZSQ .
I was able to build using bazel and I have the .tar file and I was able to put it in before, but I no longer have the tfjs-node directory and when I run the npm install command it doesn't create it anymore. How do I get the tfjs-node directory back? and will I probably need to rebuild the .tar file with bazel again I thought I switched to the 2.5 branch but perhaps I didn't.
I keep getting the following error when running a node.js file (node test.js) that imports the tfjs-node on M1. Tried what you suggested above.
dyld: lazy symbol binding failed: Symbol not found: _TF_NewStatus
Expected in: flat namespace
I tried to do the install with the 2.5 branch, and it compiles and the steps that @rodrigolive suggest run correctly, the only thing I changed is to pull the 2.5 TF branch, and changed the Bazel version to 4.1.0 like following:
USE_BAZEL_VERSION=4.1.0 bazel build --jobs 4 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow.dylib
--action_env PYTHON_BIN_PATH=/usr/bin/python
USE_BAZEL_VERSION=4.1.0 bazel build --jobs 6 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow_framework.dylib --action_env PYTHON_BIN_PATH=/usr/bin/python
The npx node-pre-gyp rebuild
builds correctly aswell.
I've just reran my own steps again, but now with GA version a4dfb8d1 v2.5.0
pulled from the Tensorflow Git repository. Everything working as expected. Both a simple node -e "tf = require('@tensorflow/tfjs-node')"
and my CNN model training session with 12 epochs and 888286 parameters worked.
@kzka90 make sure you are pulling the correct version, git checkout v2.5.0
which is a tag, not a branch!
https://github.com/tensorflow/tensorflow/releases/tag/v2.5.0
My personal versions:
MacOS=Big Sur 11.2.3
Bazel=3.7.2
(through bazelisk)
Clang=Apple clang version 12.0.0 (clang-1200.0.32.29)
(clang --version)
MacOS SDK include dir=MacOSX.sdk/usr/include/c++/4.2.1
(gcc --version)
Node=16.2.0
NPM=7.13.0
tfjs=3.6.0
(from node_modules/@tensorflow/tfjs/package.json)
tfjs-node=3.6.1
(from node_modules/@tensorflow/tfjs-node)
node-pre-gyp=0.17.0
(from node_modules/node-pre-gyp)
Just reran and I keep getting the same error.
Here is exactly what I did:
Downloaded https://github.com/tensorflow/tensorflow/releases/tag/v2.5.0
Put it inside $BUILDDIR/tensorflow
Ran the following commands
cd $BUILDDIR/tensorflow
arch -x86_64 bash
brew install bazelisk
USE_BAZEL_VERSION=4.1.0 bazel build --jobs 6 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow.dylib --action_env PYTHON_BIN_PATH=/usr/bin/python
USE_BAZEL_VERSION=4.1.0 bazel build --jobs 6 --config=macos_arm64 --config=noaws --config=nogcp --config=nohdfs --config=nonccl //tensorflow:libtensorflow_framework.dylib --action_env PYTHON_BIN_PATH=/usr/bin/python
Needed to add `PYTHON_BIN_PATH=/usr/bin/python` because it wasn't finding my Python. And I'm using the 4.1.0 of Bazel.
This compiling throws the following successful messages:
First one:
INFO: Found 1 target... Target //tensorflow:libtensorflow.dylib up-to-date: bazel-bin/tensorflow/libtensorflow.dylib INFO: Elapsed time: 3965.162s, Critical Path: 240.83s INFO: 9095 processes: 67 internal, 9028 local. INFO: Build completed successfully, 9095 total actions
Second one:
INFO: Found 1 target... Target //tensorflow:libtensorflow_framework.dylib up-to-date: bazel-bin/tensorflow/libtensorflow_framework.dylib INFO: Elapsed time: 3.620s, Critical Path: 0.23s INFO: 2 processes: 1 internal, 1 local. INFO: Build completed successfully, 2 total actions
So I can tell Bazel does it work correctly.
4. Existed the `arch -x86_64 bash` with `exit `
5. Then ran the following
cd $BUILDDIR mkdir tfjs-test && cd tfjs-test nvm use 16.2.0 npm init -y npm i node-pre-gyp npm i @tensorflow/tfjs-node@latest --ignore-scripts cd node_modules/@tensorflow/tfjs-node/ mkdir -p deps/lib deps/include/tensorflow cp -r $BUILDDIR/tensorflow/tensorflow/c deps/include/tensorflow/ cp -r $BUILDDIR/tensorflow/tensorflow/core deps/include/tensorflow/ cp -r $BUILDDIR/tensorflow/bazel-bin/tensorflow/*.dylib deps/lib/ npx node-pre-gyp rebuild
This throws the following message:
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 'build', gyp info spawn args '-Goutput_dir=.' gyp info spawn args ] gyp info ok node-pre-gyp info This Node instance does not support builds for N-API version 8 gyp info it worked if it ends with ok gyp info using node-gyp@7.1.2 gyp info using node@15.8.0 | darwin | x64 gyp info spawn make gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] CXX(target) Release/obj.target/tfjs_binding/binding/tfjs_backend.o CXX(target) Release/obj.target/tfjs_binding/binding/tfjs_binding.o SOLINK_MODULE(target) Release/tfjs_binding.node ld: warning: ignoring file /Users/user/tf-build/tfjs-test/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow_framework.2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 ld: warning: ignoring file /Users/user/tf-build/tfjs-test/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.2.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 POSTBUILD(tfjs_binding) Adjust libtensorflow load path POSTBUILD(tfjs_binding) Adjust libtensorflow_framework load path COPY /Users/user/tf-build/tfjs-test/node_modules/@tensorflow/tfjs-node/lib/napi-v7/tfjs_binding.node TOUCH Release/obj.target/action_after_build.stamp gyp info ok node-pre-gyp info ok
But when I run a test, e.g. `node -e "tf = require('@tensorflow/tfjs-node')"` still getting:
dyld: lazy symbol binding failed: Symbol not found: _TF_NewStatus Referenced from: /Users/user/tf-build/tfjs-test/node_modules/@tensorflow/tfjs-node/lib/napi-v8/tfjs_binding.node Expected in: flat namespace
dyld: Symbol not found: _TF_NewStatus Referenced from: /Users/user/tf-build/tfjs-test/node_modules/@tensorflow/tfjs-node/lib/napi-v8/tfjs_binding.node Expected in: flat namespace
zsh: abort node -e "tf = require('@tensorflow/tfjs-node')"
My versions:
MacOS=`Big Sur 11.0`
Bazel=`4.1.0`
Clang=`12.0.5`
MacOS SDK incldue dir=`MacOSX.sdk/usr/include/c++/4.2.1`
Node=`16.2.0`
NPM=`7.13.0`
tfjs-node=`3.6.1`
node-pre-gyp=`0.17.0`
@kzka90, this message:
building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Says something is wrong in your install, maybe your Node is x86_64, could that be it?
Try this:
$ file `which node`
/Users/rod/.nvm/versions/node/v16.2.0/bin/node: Mach-O 64-bit executable arm64
It should be an arm64 binary, not x86_64.
@rodrigolive Yes, it throws x86_64
Thanks. Now I've spotted the problem and I've tried a lot of cleans and re-installs, but NVM keeps installing the x86_64
on my node
version 😔.
Can't manage to get the arm64
for some reason. But that issue is not relevant for this channel. I'll see what I can do to get it build for arm64
. Weird cause uname -m
on my Terminal throws arm64
.
@rthadur:
@ALL can you please confirm if this is resolved after 2.5 release ? Thank you
So, the issue is not resolved, it needs a PR so that TFJS installs on Apple Silicon, which means:
1) bumping TFJS support from 2.4.1 to 2.5.0 (const LIBTENSORFLOW_VERSION = '2.4.1';
) and change install scripts under tfjs-node/scripts
.
2) upload a compiled and packaged TensorFlow-for-macos/darwin-arm64 libs to the googlestorage account that holds all platform specific binaries here: https://storage.googleapis.com/tensorflow/libtensorflow/
3) upload all the other libs for the rest of archs/platforms, all bumped to 2.5.0
I can create the TFJS install patch for 1), but I don't see any procedures, if any, to build and release the TensorFlow binaries to the googlestorage account. Is this automated somewhere with the release?
cc @pyu10055 can you please let @rodrigolive know, if he can submit PR bumping TF version ?
@rodrigolive the tensorflow platform binary files are auto-generated, currently M1 is not officially supported, thus the binary is not available on the tensorflow gcp storage.
@kzka90 seems when you build tensorflow you specified following:
arch -x86_64 bash
wondering if that would be the cause of the wrong arch build.
Looks like in the short term, you need to manually built the tensorflow binary and copy them to tfjs-node directory, until M1 is officially supported. or you can host the compiled arm64 build in a cloud storage, you can use the node env variable specified here to install the specific binary you have build.
I've just successfully built and ran my models with tfjs-node 3.5.0 with TensorFlow 2.5.0-rc1 on my M1 Macbook Air. From what I could see, the yet-to-be released TF 2.5.0 is where Apple Silicon is supported, but pre-release 2.5.0-rc1 is already fully usable.
I can confirm the @rodrigolive method works for me on an M1 air. The only thing I changed was bazel version to 4.1.0 and I dropped the RC tag on tensor and changed it to 2.5.0. I also did not need to do arch -x86_64 bash
. I had to install numpy for python3. I am using nvm and installed node v14.17.0. I have homebrew and xcode installed, etc, nothing out of the ordinary.
Closing as stale. Please @mention us if this needs more attention.
Any word/ETA on official support?
Any word/ETA on official support?
I'd love to know when it's available as well!
Why is this closed? There is a workaround but it makes common development workflows tedious.
Why is this closed? There is a workaround but it makes common development workflows tedious.
Yeah, hoping this issue can be re-opened. TF.js is the only dependency preventing me from having a native development experience for my projects, so it would be nice to see a proper resolution to this.
I'm currently using a libtensorflow binary compiled under x86/Rosetta 2. I tried compiling for darwin-arm64 but ran into issues with Bazel.
Why is this closed? There is a workaround but it makes common development workflows tedious.
Yeah, hoping this issue can be re-opened. TF.js is the only dependency preventing me from having a native development experience for my projects, so it would be nice to see a proper resolution to this.
I'm currently using a libtensorflow binary compiled under x86/Rosetta 2. I tried compiling for darwin-arm64 but ran into issues with Bazel.
Agree! I've decided to just not dev with TF.js on my mac and just use my windows pc
Why is this closed? There is a workaround but it makes common development workflows tedious.
Yeah, hoping this issue can be re-opened. TF.js is the only dependency preventing me from having a native development experience for my projects, so it would be nice to see a proper resolution to this. I'm currently using a libtensorflow binary compiled under x86/Rosetta 2. I tried compiling for darwin-arm64 but ran into issues with Bazel.
Agree! I've decided to just not dev with TF.js on my mac and just use my windows pc
I third that!
For anyone who for some reason needs to work on a part of their repo that doesn't touch node-tfjs
but does need to have npm install
work; a possible workaround is:
npm install @tensorflow/tfjs-node --ignore-scripts
then
npm install
For anyone who for some reason needs to work on a part of their repo that doesn't touch
node-tfjs
but does need to havenpm install
work; a possible workaround is:
npm install @tensorflow/tfjs-node --ignore-scripts
then
npm install
it gets installed but when compiling it pops an issue and says to rebuild it. Rebuilding gives the same "Unsupported system: cpu-darwin-arm64" error.
@mowaisch That makes sense if there is still a require("@tensorflow/tfjs-node")
statement in a file that's being build. Please be aware the --ignore-scripts
solution only works if none of the build files actually import the package.
This is for example possible if you have multiple buildable projects in a single npm
project or if there are some graveyard files which for some reason aren't used but also aren't deleted from the repo.
If you can live with the speed of the JS-based backend, a simple workaround is to use @tensorflow/tfjs
instead of @tensorflow/tfjs-node
.
Need M1 mac support!
Have there been any updates here? Given that apple silicon isn't going away, there's a lot of potential impact in unblocking this
System information
Describe the problem
Installation fails due to a missing precompiled
libtensorflow
for darwin / arm64.Apple has their own fork of TensorFlow supporting their chips-- is there a way to tell the installation script to use their
libtensorflow.dylib
?Provide the exact sequence of commands / steps that you executed before running into the problem
npm install @tensorflow/tfjs-node --save
Any other info / logs