Skip to content
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

Support for M1 Macs #152

Open
smmaurer opened this issue Dec 8, 2020 · 3 comments
Open

Support for M1 Macs #152

smmaurer opened this issue Dec 8, 2020 · 3 comments

Comments

@smmaurer
Copy link
Member

smmaurer commented Dec 8, 2020

-- SEE UPDATES LATER IN THREAD --

Pandana runs on the new M1 ARM-based Macs without much trouble.

Installing Python

One option is to install Anaconda in the normal way, which for now gives you x86 binaries that runs through a translation layer. All the Python libraries I tried ran fine as x86 binaries. Performance was similar to my i7 MacBook Pro.

The Conda Forge team is doing great work with ARM builds, though. So another option is to install the osx-arm64 build of MiniForge from here. This will set you up to conda-install the ARM builds of packages on Conda Forge, which there are already quite a lot of. More info about the Conda Forge work here: https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/

Installing Pandana

If you're using an x86 Python installation, you can install Pandana in any normal way (conda, pip, etc).

To get ARM binaries for Pandana, you'll need to compile locally. In my testing, the performance is about 35% better. It seems like Python environments need to be either all-x86 or all-ARM.

  1. Clone the osx-arm64 Pandana branch from GitHub.

  2. Conda-install the key dependencies: clang, llvm-openmp, cython, numpy, pandas, scikit-learn. You should see in the status messages that you're getting osx-arm64 binaries.

  3. Compile & install Pandana with python setup.py develop.

    I ran into a glitch involving a "No such file or directory" error after a compilation command that used arm64-apple-darwin20.0.0-clang++. I fixed it by going into the MiniForge binaries folder (find it with which clang) and renaming the clang++ file with the longer name. This will probably be fixed upstream at some point.

That should do it! The only caveat is that there's no PyTables build for ARM at this point, so you will not be able to work with h5 files.

What's different in the osx-arm64 branch?

  • Replaced distutils with the newer setuptools, which correctly detects that ARM should be the compilation target.

  • Commented out the PyTables dependency, because there isn't an ARM build available yet.

  • Commented out C++ code related to hyper-threading, because it included some lines of x86 assembly that couldn't be compiled on ARM. The M1 does not use hyper-threading (just one process per core rather than two), so there's no performance loss. But we'll need to clean this up before merging the branch.

Next steps

It sounds like an osx-arm64 build of Pandana on Conda Forge should be straightforward (see blog post above). But at this point it's held up by the PyTables dependency.

@chourmo
Copy link

chourmo commented Mar 13, 2021

It seems that an osx-arm64 build of pytables is available on conda-forge
https://anaconda.org/conda-forge/pytables

@smmaurer
Copy link
Member Author

@chourmo Oh, great! I'll clean up the osx-arm64 branch accordingly, and we should be able to publish ARM builds of Pandana too.

This was referenced Mar 15, 2021
@smmaurer
Copy link
Member Author

Binary installers for Pandana on osx-arm64 are now available from Conda Forge 🎉

Here's the current state of things. Note that it's not a problem to run older x86 Python installations and packages, including Pandana, on ARM Macs. These adjustments are just to support native compilation, which improves performance.

Installing from Conda Forge on ARM Macs

  1. Install MiniForge for osx-arm64 (read, download).

  2. conda install pandana

    Check the install messages to confirm you're getting osx-arm64 binaries.

Compiling locally for ARM

Assumes you're using a copy of the codebase post-PR #159.

  1. Install MiniForge for osx-arm64 (read, download).

  2. Install all of Pandana's build- and runtime requirements from Conda. Check the install messages to confirm you're getting osx-arm64 binaries.

    conda install clang llvm-openmp cython numpy pandas scikit-learn pytables

  3. Compile and install Pandana.

    python setup.py develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants