UDST / pandana

Pandas Network Analysis by UrbanSim: fast accessibility metrics and shortest paths, using contraction hierarchies :world_map:
http://udst.github.io/pandana
GNU Affero General Public License v3.0
385 stars 84 forks source link

Support for M1 Macs #152

Open smmaurer opened 3 years ago

smmaurer commented 3 years ago

-- 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?

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 commented 3 years ago

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

smmaurer commented 3 years ago

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

smmaurer commented 3 years ago

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

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