-
Notifications
You must be signed in to change notification settings - Fork 74.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make TensorFlow build on Apple Silicon #45404
Make TensorFlow build on Apple Silicon #45404
Conversation
/cc @mihaimaruseac |
Thanks for sharing the patch. I tried building it, but got this error. I'm using a custom bazel build for aarch64 M1
|
Interesting, how did you build Bazel for arm64? Maybe you can share your patch and help fixing bazelbuild/bazel#11628? 😃 I'm running Bazel 3.7.1 built for x86_64 under the emulator on an Apple Silicon DTK. Not sure if it's the custom patch that caused the problem, it would be very helpful if you could share the patch. Also can you add |
b5f34df
to
0ce88e8
Compare
Would it be possible to share a compiled wheel of Tensorflow cpu for python 3.9 for macosx-arm64 / M1?
I build bazel from source and used the Zulu Java JDK, download zulu13.35.1017-ca-jdk13.0.5.1-macos_aarch64.dmg from
No patch needed from the release package, except for a minor one (which is already fixed in master( I downloaded the latest bazel release, instead of using git clone)
Here is a precompiled binary for macos-arm64: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch!
@erwincoumans I spent some time debugging this issue. It turned out TF detects the execution platform info at
This needs some tweaks from both Bazel side and TF's side, I'll send some PRs to make it work. In the meantime, you can use the x86_64 Bazel binary to build TF on Apple Silicon. |
Apple released the prebuilt TF artifacts here: https://github.com/apple/tensorflow_macos/releases |
Oh, aarch64 is actually arm64, in this case, we just have to fix TF's remote_platform_configure.bzl to return |
that artifact is using python 3.8, I am looking for a buid using Python 3.9... |
Update two findings while trying to get TF up and running on Apple Silicon:
|
Revert the build_pip_package.sh change in #45404 , which caused the keras package to be under unexpected tensorflow.python.keras PiperOrigin-RevId: 352513398 Change-Id: Ic8f0448cbbe535faba8f774489276be59efbee34
Hi! I'm using bazel 3.7.1 arm to build tensorflow on Apple M1 like this:
It builds for a long time then it stops with this error:
Any ideas what could be wrong? Seams like it tries to build x86 stuff? |
Hi, are you using a custom Bazel binary built for arm64? Bazel doesn't provide official Apple Silicon support yet, see bazelbuild/bazel#11628. Can you try with the x86 Bazel 3.7.1 binary? It runs seamlessly with Rosetta 2. |
Hi! I've tried the x86 Bazel 3.7.1. you linked to. It gave me another error when building standard tensorflow:
After that I tried your fork but it failed another way:
|
@vashat |
@meteorcloudy After that I cloned your fork, checked out apple_silicon_build and run ./configure:
./configure gave me the following questions which I chose the default answers on. Note that it did not list "macos_arm64" as an option in the --config part at the end. Maybe that is the problem? It also told me that i can't use bazel 3.7.1, 3.7.2 is needed to build. So I installed the x86 version of 3.7.2. See the options I got:
After then I started building. It built for several hours and ended in this error:
|
@meteorcloudy |
How could I build a arm64 .whl file
But it still not seems to work
|
@Huibean |
@meteorcloudy I have build it with |
@erwincoumans have you figured out |
This is mostly likely you don't have Xcode installed, please install Xcode then do |
@meteorcloudy Thanks, that indeed fixes my issue. |
does anyone know how to install tensorflow version 2.1.0 on the M1 mac? |
2.1 is too old for that. You should try 2.4/2.5 and later. |
The apple developers gave me the approval to upstream this patch that makes TensorFlow build on Apple Silicon.
The build works with the following setup:
Bazel: x86_64 3.7.1 through Rosetta
Python: 3.8.2 You can setup up a Python virtual environment and install all the pip dependencies built for arm64 following the instruction at https://github.com/apple/tensorflow_macos#details
Xcode version: 12.3
then you can build TensorFlow on Apple Silicon with
Related: #44751