-
Notifications
You must be signed in to change notification settings - Fork 13
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
Build for Apple M1 silicon #49
Comments
I think conda-forge is using a cross-compiling setup to build the https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/ The cross-compilation feature is apparently a feature of Note (for openblas): the conda-forge macos/arm64 build recipe sets the target to |
It's not hard if you are using the compilers from Apple and is not using conda. You already do a kind of cross compiling when build |
But to build openblas, one needs a gfortran setup that is ARM64 compatible (including the libgortran runtime that has to be vendored in the wheels with I assume that in this case one would have to upgrade on something like the following experimental releases: https://github.com/fxcoudert/gfortran-for-macOS when building for the macos/arm64 target, while keeping the mavericks version when targeting 10.9. but this ARM64 version is not meant to run on a x86_64 host AFAIK. |
In scipy/scipy#13347 we'd like to update minimum GCC to >= 5.5, for that to happen we'd need to upgrade gfortran also. Re this issue: last I checked Apple didn't really care about Fortran and there was no solution for Fotran on ARM64 yet. Some Julia folks were loudly complaining on Twitter. Not sure if anything has changed since then? |
Apparently the conda-forge team (@isuruf and others) managed to build a working gfortran that is enough to build a working scipy stack (based on openblas) from source on Apple M1. I asked @fxcoudert whether the |
Hello 👋 Current status of gfortran:
As part of Homebrew (where I am a maintainer):
Regarding cross-compilation:
I don't have time right now to build one and host it on my page, but I can help you if you have questions or issues. |
If we are going the route of releasing cross-compiled binaries with no ability to test the that the package works (something I am not in favor of), it would make sense to host the compiler chain somewhere public so that each project would not have to build its own. |
We have a x86_64 to arm64 darwin cross-compiler built from iains fork above in conda-forge, but it's the 11.0.0 dev branch and not the 10.x branch that @fxcoudert mentioned. It works really great and we have built a lot of the pydata stack including scipy with these compilers. Here are some things we can do,
Building fat binaries is not possible, but a shell script wrapper that uses the two compilers and fuse them using lipo might not be too hard. |
The alternative would be to wait for public Continuous Integration services to add Apple M1-based builders but as far as I know there is no ETA for that. So cross-compiling on public CI workers + local manual testing from time to time seems to be the only option for the time being. |
@fxcoudert, looks like |
@isuruf Thanks, I'll update. |
I am not even sure that fat binaries are needed. What people really want is |
The problem may be that the packaging people chose fat wheels and a fat python.org Python installer by default. It's a really weird choice of course, but if that's all If that does work fine, then I'm all for no fat wheels. The extra space and bandwidth that takes is useless (we're also not stuffing 32/64-bit Windows together, or x86/arm64 Linux). |
I would vote for: let's start with trying to get thin wheels to work. If pip does not like them (e.g. by trying with test.pypi.org), then we can try to hack around to fuse them as suggested by @isuruf in #49 (comment). The short term blocker is to get a maintainable gfortran cross-compiling tool chain. I think it's good to mutualise this maintenance effort with homebrew and conda-forge developers. Out of curiosity, @fxcoudert how do you build the arm64 compatible binaries for openblas in homebrew at the moment? Do you have access to some public CI service with M1 workers? Or do you host your own farm of M1-based mac minis somewhere? |
My guess would be that that two thin wheels won't work, because the Python.org How does the Python.org binary work? Does it start in M1 mode by default, or x86_64 mode by default? If it starts in M1 mode by default, and it will be rare to start in x86_64 mode, then we could consider a thin M1 wheel, with a Fusing is fiddly but not difficult. There were a few recipes for Multibuild that used to do that to make i386 / x86_64 fat wheels. |
I installed Python 3.9 from python.org and it does get executed in ARM64 mode by default:
|
Here's a cross compiling toolchain I scribbled together from the conda toolchain removing conda specific parts |
@ogrisel Homebrew hosts its own Apple Silicon machines |
Updated link from comment above: multi-build/multibuild#383 There are arm64 builds for this repo now:
|
I am not sure how we can convince multibuild/CMake to build OpenBLAS for Apple M1 silicon. Can we directly use the ARM64 artifact?
The text was updated successfully, but these errors were encountered: