tfjs: Unsupported system error when installing on M1 / Apple Silicon
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS 11.0.1 (20B29)
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version: 2.8.3
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
npm ERR! code 1
npm ERR! path /Users/nicklee/Documents/Development/<redacted>/src/<redacted>/node_modules/@tensorflow/tfjs-node
npm ERR! command failed
npm ERR! command sh -c node scripts/install.js
npm ERR! CPU-darwin-2.8.3.tar.gz
npm ERR! * Downloading libtensorflow
npm ERR! /Users/nicklee/Documents/Development/<redacted>/src/<redacted>/node_modules/@tensorflow/tfjs-node/scripts/install.js:100
npm ERR! throw new Error(`Unsupported system: ${libType}-${platform}-${os.arch()}`);
npm ERR! ^
npm ERR!
npm ERR! Error: Unsupported system: cpu-darwin-arm64
npm ERR! at getPlatformLibtensorflowUri (/Users/nicklee/Documents/Development/<redacted>/src/<redacted>/node_modules/@tensorflow/tfjs-node/scripts/install.js:100:11)
npm ERR! at downloadLibtensorflow (/Users/nicklee/Documents/Development/<redacted>/src/<redacted>/node_modules/@tensorflow/tfjs-node/scripts/install.js:134:7)
npm ERR! at async run (/Users/nicklee/Documents/Development/<redacted>/src/<redacted>/node_modules/@tensorflow/tfjs-node/scripts/install.js:197:5)
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/nicklee/.npm/_logs/2021-01-09T02_53_09_673Z-debug.log
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 15
- Comments: 102 (9 by maintainers)
Commits related to this issue
- Adds required docker configurations to run this on an M1 Mac without workarounds or hacks. See https://github.com/tensorflow/tfjs/issues/4514 for progress updates. — committed to mattsgarrison/learn-tfjs by deleted user 3 years ago
- update darwin-arm64 download url to tfjs gcp bucket (#5899) TF does not provide binary for OSX M1 hardware, we need to create our own build to enable tjfs-node on M1 machines. Compiled darwin-arm6... — committed to tensorflow/tfjs by pyu10055 3 years ago
Need M1 mac support!
We are expecting to release a new version next week. Thanks for the patience.
On Fri, Dec 3, 2021 at 6:12 PM Charlie Fish @.***> wrote:
To use the precompiled libraries from @vodianyk (https://github.com/vodianyk/libtensorflow-cpu-darwin-arm64) just use the last part of my instructions, posted earlier.
Disclaimer: I’m not affiliated nor can vouch for the safety of a binary downloaded from a private Github account! Use at your own risk!
I’m also not sure this combination of
tfjs-node@latestandlibtensorflow-2.8.0is the correct pick, but it doesn’t look bad.And you’re all set.
Why is this closed? There is a workaround but it makes common development workflows tedious.
Any update on this issue by any chance? Experiencing the exact same dylib error.
Latest release works 😃
Same issue with @GitHelge, would be great if there’s a resolution for docker!
I don’t want to wait any longer!
Any word/ETA on official support?
@pyu10055 Do you have any thoughts about this on Docker?
@fishcharlie I think another solution is for tfjs team to supply a semi-official M1 TF binary. If some can share a working docker file, we can build and release a new version of tfjs-node that using the binary we built. Since we don’t have M1 hardware, would need your help to verify the validity of the build.
I really don’t want to add too much noise here. But @pyu10055 it looks like this issue is assigned to you. Can you please provide us an update on the status of this? Or maybe @rthadur since you have reopened this issue multiple times?
The fact that there hasn’t been any official word regarding the status of this is really disappointing considering how many people are simply asking for a simple status update.
I respect that open source is very community driven, and things get busy. But this project is maintained by Google. Additionally, providing a simple status update or ETA I don’t believe is unreasonable to expect.
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.
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).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.
Are you satisfied with the resolution of your issue? Yes No
for Monterey, tfjs-node is installed, but while running code gives error
zsh: illegal hardware instruction node ./index.jsIm running the new version on my M1. Locally it works fine but when using docker, it runs into this issue:
I think the the PR enabled the function for cpu-darwin-arm64 but not for cpu-linux-arm64. Does anyone know if support for linux/arm64 is planned?
Just use instructions from tensorflow website: https://www.tensorflow.org/install/lang_c
I agree with you on this. We urgently need to be informed about a roadmap or estimated time of resolution.
I regret buying M1 so much
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.
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.
Nice that https://github.com/tensorflow/tfjs/pull/5899 got merged!
Now we just have to wait for the next release to happen. Or is there some pre-release tag on npm that we can use that have this?
Thank you for verifying, this is an official build from us, will update TFJS-node package to use the TF arm64 binary in our gcp storage.
On Thu, Nov 25, 2021 at 10:37 AM Charlie Fish @.***> wrote:
I third that!
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 for2.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_arm64seems 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.Source: https://github.com/tensorflow/tensorflow/pull/45404
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 😃
so far no luck with monterey.
tried . tfjs-node 3.15,3.5 & node 14,16 & build my own tensorflow 2.5 & used posted tensorflow 2.7 builds too. has anyone tried out in monterey ?
But the main reason i am posting is to ask for any idea or even it would be possible to use the instance of Tensorflow on Conda Env. with Metal Plugin (which i already succeded to run GPU based Tensorflow runs) . I think somehow configuring tfjs-node wrapper to use Apple’s supported platform will encourage people to use tfjs-node much much more.
@pyu10055 Awesome!! Let me know if I can assist any further. Can’t wait for this update to be released to npm!
@pyu10055 As far as I can tell, it works great!! Here is the steps I took to test it:
customvision-tfjs-nodedirectory, rannpm i ~/Downloads/tensorflow-tfjs-node-0.0.0.tar(path to the downloaded file in step 1)npm i ~/Downloads/customvision-tfjs-node(path to cloned repo in step 2)Side note: I feel like at this point either step 3 or 5 would have failed. However, I have received no errors, so far, so I kept going.
Please let me know if there are any further tests you would like me to run. I have only run these tests on an Apple Silicon machine (M1 Max) without Rosetta 2 running 🎉. If you would like me to run on a machine with Rosetta 2 installed, or an Intel machine, please let me know and I have access to both environments, and can run those tests.
@pyu10055 I would be more than happy to help assist in testing an Apple Silicon/M1 build on my hardware. However, one thing to note, my experience with tfjs is limited to customvision-tfjs-node. So that will likely be the extent I’ll be able to do manual tests. It looks like there are automated tests in this repo tho? So I can possibly run those. Might need some guidance about the tests we want to run to verify validity.
Short version: I’d be more than happy to help in whatever capacity I can.
In case it’s helpful, I have a compiled version of tensorflow shared libs for M1: https://github.com/vodianyk/libtensorflow-cpu-darwin-arm64
@rodrigolive Yes, it throws
x86_64Thanks. Now I’ve spotted the problem and I’ve tried a lot of cleans and re-installs, but NVM keeps installing the
x86_64on mynodeversion 😔.Can’t manage to get the
arm64for some reason. But that issue is not relevant for this channel. I’ll see what I can do to get it build forarm64. Weird causeuname -mon my Terminal throwsarm64.@tensorflow-butler please do not close, it is awaiting 2.5.0 release to be completed, but still important.