-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Provide wheels for macOS ARM #5501
Comments
Targeting the M1's ARM CPU shouldn't be difficult. XLA already supports AArch64 and has done for a long time. I suspect that tensorflow/tensorflow#45404 already did most of the work to adapt XLA to build on the M1 and all that is left is a few small changes to the That said, I don't have access to any M1 hardware, so this is in the "contributions welcome" category. Targeting the GPU or the Neural Engine is likely a lot more difficult. For GPU, one would probably need to target Metal (probably doable, but not trivial), and I'm unsure how we could target the Neural Engine at this time. |
Hi! I have tried to get jaxlib working now on my apple m1, and have managed to build it with some minor changes according to tensorflow/tensorflow#45404 (branch on https://github.com/jotsif/jax/tree/jax_for_darwin_arm64). However when loading jaxlib in python3 (3.9.2) I get the import error Seems to be a known issue from comment here tensorflow/tensorflow#45404 (comment) and here elixir-nx/nx#217 (comment). I am investigating further but if anyone has any tip that would be welcome. |
Update: this TF PR will probably fix this issue tensorflow/tensorflow#47594 |
@jotsif thanks for that information, that's really helpful! |
Confirmed that it works 🎉 . Built with Bazel master, and https://github.com/freedomtan/tensorflow/tree/bazel_native_build_on_m1
@mattjj @hawkinsp If you want a PR I would be happy to create one, but maybe it makes more sense to wait until bazel has released a working native arm64 build and tensorflow have the necessary code in master. |
Congrats! Do you mind sharing a jax/jaxlib wheel for M1? |
Hi @jotsif - Bazel 4.1 works natively with arm64 - bazelbuild/bazel#13099 and TF has necessary code in master. If you have an example branch, i'm happy to help towards a PR now! |
@akbir I think we still need to wait for Bazel to actually release 4.1. But that should be soon I think! At that point we can probably just bump the Bazel dependency to 4.1 and hopefully everything should work on Mac ARM. We can look into releasing Mac ARM wheels as well, although we don't yet have a way to test them (we personally do not have Mac ARM hardware yet), which gives me some pause. |
…res on Mac M1. jax-ml/jax#5501 PiperOrigin-RevId: 374601482 Change-Id: If7b36f6963c74770522d06865d0800811ce63f81
I believe now that at head (*) It's a bit annoying to install |
Hi @hawkinsp - tried following this but hit the following error when running
Unsure why toolchain isn't working an error is discussed here: bazelbuild/bazel#13099 (comment). I've also run build against bazel 4.1.0.rc5 and still get the same error. Full error logs:
|
Getting same error as @akbir .
|
FYI for those looking for a quick and dirty workaround, you can install |
@akbir Do you have a working XCode installation including the command line tools? I don't think the error you are seeing is related to the Bazel version. We're currently pinning Bazel 4.1.0rc4 because that was the newest version last week. If you like you can try a different Bazel version, but 4.1.0rc4 worked for me. The easiest way to do that is to install Bazel yourself and pass @Noahyt jaxlib 0.1.62 and newer on x86 use AVX, which Rosetta does not support (https://github.com/google/jax/blob/master/CHANGELOG.md#jaxlib-0162-march-9-2021). All recent x86 CPUs support AVX and have for a long time. We don't intend to ship wheels without AVX, although if you like you can build a jaxlib from source that does not require AVX. But I don't think we should worry about that too much, since we want a native ARM version, anyway. |
Got this to finally build!! Thank you @hawkinsp For others, I installed Xcode (not just command-line interface) and Bazel. Also updated
|
@akbir If you want to send a PR that updates the Bazel version for Mac ARM, that sounds great! The version of bazel is chosen here: https://cs.opensource.google/jax/jax/+/master:build/build.py;drc=dacf31f2020175181014745cdabc240a10031227;l=119 |
would love to! quick question - why does jax also specify the version here: https://github.com/google/jax/blob/master/.bazelversion ? |
@akbir If I remember correctly, that's for folks using Bazelisk (https://github.com/bazelbuild/bazelisk). I don't know if it's possible to specify a separate version for Mac arm via Bazelisk. We can probably upgrade to 4.1.0 for all platforms, but let's not do that right away. So fixing |
I have tried the solution proposed by dfm and yashk2810 with no success. while yashk2810's approach gives me |
You should be able to just From yashk:
|
THANKS, and would it be supported for py3.8 on maxos arm64? |
We don't provide 3.8 wheels for mac arm64, only 3.9 and 3.10. (I think originally we were under the impression that 3.8 was never released for Mac ARM, although I guess that's not true.) I guess we could, though. |
I had the same problem. Since I already had Anaconda installed and didn't want to clutter up my space with Anaconda + miniconda + homebrew and whatever, what worked for my was installing
|
The conda packages from
|
@gabrieldernbach Can you enlighten me what didn't work with the conda packages? Since yesterday new versions are up that should work. |
By far the easiest solution for me was to re-install Python using the latest arm64 version of Miniforge (not Miniconda) then |
I've tried this, and it works!! This video might be useful for people already using miniconda, that want miniforge on the side or as default. |
Hi all, I just upgraded from an Intel Mac to an M2 Mac and read this thread. What is the best way for my to proceed in terms of installing JAX on the M2? Is it possible to build JAX to work with Apple GPU in addition to CPUs? Thanks and apologies in advance if I missed this in the discussion above! |
Is this CPU only? How about Apple GPU cores, or maybe even the Neural Engines? |
Hi all,
I was digging around to see what might need to happen to allow JAX to work on Apple Silicon. Knowing that JAX gets compiled to XLA, my guess here is that XLA would need to be made Apple Silicon-compatible first before JAX could run on it. May I ask, do you all know if there are plans on the XLA team to make that happen, or is it being ignored completely? (Knowing the answer can help me make some decisions on how I should set up my development environment mostly.)
Cheers,
Eric
The text was updated successfully, but these errors were encountered: