-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Fix Darwin ARM64 build (macOS/M1 support) #16621
Conversation
@thomasdesr @scv119 can you help check this PR? |
@simonfall Thanks for putting this together. I've made several attempts to get bazel built from source and been failing so far. Could you share the process you followed to build bazel from source? |
Sorry I don't have a M1 machine for verifying this change :'( |
Edit: Use Bazel 4.2.0rc1 through Bazelisk. Original comment: @thomasdesr Sure, here are the steps I followed:
Let me know if this works for you :) PS: AFAIK, the Bazel team actively worked on Apple Silicon support in the last weeks. You could try to simply reinstall an up-to-date release candidate and see if it works to build Ray. |
Hey @simonfall ! Thanks for the instructions. Things aren't quite working for me yet but we've definitely made some serious progress! Everything is now happily compling but I'm failing when trying to link the raylet. Output:
I think the critical piece of that is this:
Did you hit this error? |
@thomasdesr librt doesn't exist on macOS. This error basically means that some dependency references Linux code where it should select macOS code (or your Bazel version selects the wrong toolchain). The fixes in this PR should define working dependencies. Have you tried PS: Also make sure you've built Bazel from the right branch (branch |
Hey! I got a hold of a new M1 to try again from scratch on a clean everything. Unfortunately I reproduced the same behavior (missing |
I am trying to get ray to build/work on my macOS/M1, and this patch is very helpful! Thank you, @simonfall. With this patch and this version of bazel, https://github.com/erwincoumans/bazel/releases/tag/bazel-3.7.1-mac-arm64, build: Do you happen to have any insights on this? Is is because I am not using the manual build of bazel 4.2 build mentioned here or ??? |
One other followup on my last comment: The undefined symbols for architecture arm64 are coming |
@amholler AFAICT, missing symbols come from linking Linux libs where macOS system libs would have provided the right symbols. Also I think that upgrading Ray's dependencies to the latest versions will require more effort than simply bumping up version numbers. @thomasdesr @amholler I'll do a clean build in the next days and give you an update. It is crucial that you use a Bazel version which includes the mentioned fix (branch 4.1.0-unix-toolchain-fix-for-darwin-arm64, HEAD at 0ad9fac9b3d24e78f91c831c393520787022e2a1). Other versions might succeed in building the targets, but the targets will not run correctly. |
Thanks @simonfall BTW, would it be possible for you to provide a wheel for your M1 build of Ray? |
@amholler Find a wheel here. Let me know if you need anything else. Edit: Updated release. |
Hi, @simonfall, Thanks for posting your wheels!
|
@thomasdesr I checked the PR with a clean environment and it seems like renaming $ brew uninstall bazel
$ brew install bazelisk
$ export USE_BAZEL_VERSION=4.2.0rc1
$ bazel --version
bazel 4.2.0rc1 With Bazel 4.2.0rc1 and Xcode.app in the trash, the build works as expected and tests pass. |
Edit: environment wasn't clean but contained dummy @amholler I rebuilt the required wheels in a clean environment, see this release. The following steps should work to use Ray with conda: $ wget https://github.com/simonfall/ray/releases/download/2.0.0.dev0/ray-2.0.0.dev0-cp39-cp39-macosx_11_0_arm64.whl \
https://github.com/simonfall/ray/releases/download/2.0.0.dev0/py_spy-0.3.7-py2.py3-none-macosx_11_0_arm64.whl \
https://github.com/simonfall/ray/releases/download/2.0.0.dev0/dm_tree-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
$ conda create -y -n test_ray python=3.9.5 numpy scipy pandas matplotlib grpcio
$ conda activate test_ray
$ pip install py_spy-0.3.7-py2.py3-none-macosx_11_0_arm64.whl
$ pip install dm_tree-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
$ pip install "ray-2.0.0.dev0-cp39-cp39-macosx_11_0_arm64.whl[default]" |
Thanks, @simonfall ! Install of the wheels still doesn't work for me, though the otool output looks cleaner.
|
@amholler This is not true, see below |
@simonfall Thank you for all your efforts! Unfortunately, I got exactly the same error as @amholler described from installing the linked wheels, and not under Rosetta (
|
Hi, @simonfall, Thanks. Like for @nuscire the output of arch is arm64:
Checking my conda list, all packages look arm64 except a few noarch
|
One more thing (cc @simonfall @nuscire ), I can see that _raylet.so contains librt.so using otool -l. |
@thomasdesr @nuscire @amholler Finally found the issue. You were right, and of course the |
@simonfall @amholler Cheers! we can finally get a working |
@simonfall @nuscire hey, I've tried your solution with a dummy
|
@iamhatesz Try to make the dummy
|
This worked for me! Thanks so much! Looking forward to the release. |
@simonfall follow the same step. It works for python3.9. However, similar issue about
Tried to create dummy one and below info came with.
|
Bazel 4.2.0 https://github.com/bazelbuild/bazel/releases/tag/4.2.0 released. |
I have the same issue as @cb0207, is there any way to fix import error on build 1.4.0 (Apple M1) for py3.8 ? |
Hi guys, what's the status on this PR? I got issued an M1 laptop, and would really like this to get fixed soon :) I tried to follow the steps here (using 4.2.1 bazel, so I didn't have to build that) But I was able to build a lot of stuff if I comment out those 2 patches, until it failed at some assembly code from boost library.
Any idea what may be the problem here? I thought we are pulling a different boost package via https://github.com/nelhage/rules_boost/archive/652b21e35e4eeed5579e696da0facbe8dba52b1f.tar.gz ?? Thanks |
happy to report that if I pull in the same boost tarball and patch, just drop the grpc patch, I can actually successfully build ray on my M1. |
@gjoliver Thank you for figuring this out! Unfortunately, I wasn't able to reproduce the build from the steps mentioned in your comment. Would you mind clarifying the required steps or posting a patch? |
Sure.
And together, I was able to build everything. |
From my perspective, there are three options to proceed and provide builds for ARM Macs:
@simon-mo @thomasdesr What do you prefer? |
Hey Guys, So I figured out the offending dependency. It's civetweb, pulled in via prometheus_cpp library. should we start submitting things, so developers on M1s are unblocked? |
@gjoliver do you know if there's a way to test this in our CI? Either way, it would be great if you could submit that patch as PR and tag me in it. |
@gjoliver an I chatted offline and came up with a plan. We'll add support in 3 steps:
Hopefully if anything breaks this. will make it easy to narrow down. |
I have merged the other ARM build PR. |
Thanks for all the great work on this. Can someone please share a precompiled ray wheel for M1 arm64 python 3.9? |
@erwincoumans We will provide M1 wheels for the Ray 1.8.0 release which will be released this week :) |
Hi all, Ray 1.8.0 was officially released today. Please find M1 wheels here. |
Is there also a possibility to run Ray in Docker on the M1? I tried cross compiling for linux x64 (using buildx build --platform linux/x64), but that does not work correctly on the M1. Installing and running Ray directly without Docker is working fine. Thanks! |
Why don't you just use a linux wheel? |
the Linux wheel is not supported on arm and building for linux/x64 and emulating does not work properly |
oh I see. yeah, we don't have official linux arm build yet, but I heard building ARM wheels for linux is generally working out of the box. |
Why are these changes needed?
This PR fixes the wheel build for platform "darwin_arm64" to support Macs with Apple's M1 chipset.
0ad9fac9b3d24e78f91c831c393520787022e2a1
, branch4.1.0-unix-toolchain-fix-for-darwin-arm64
)Related issue number
Fixes #14697
Note that until Bazel 4.2.0 is released, Bazel must either be built from source or the toolchain must be manually configured.
Checks
scripts/format.sh
to lint the changes in this PR.