I have been experimenting with running TVM on a new Apple Silicon Mac and wanted to start recording workarounds and instructions here as we start to gain support for running on M1 Macs.
I found some useful notes on getting setup with standard Mac tools here, currently homebrew doesn’t fully work on macOS aarm64 but you can install it and many formulas are already working.
You can easily setup XCode and Homebrew using these instructions: https://github.com/mikelxc/Workarounds-for-ARM-mac.
Currently many popular Python packages including NumPy don’t work out of the box on the M1.
I found the most robust way to get started right now is using a special version of Miniconda being built for M1 by Conda Forge. You can read more about how to install it here: https://conda-forge.org/blog/posts/2020-10-29-macos-arm64/.
You can then use this to do:
conda install numpy decorator attrs cython
and any other TVM dependencies you need.
You can also get a fresh build of LLVM-11 from Conda.
conda install llvmdev
You can then set
llvm-config which should be installed in Conda bin path.
You can also install CMake via Conda.
conda install cmake
As this issue discusses currently CMake will default to building a fat-binary build on macOS architectures on Big Sur (from my understanding) resulting in TVM’s build attempting to link an x86-64 version of TVM to an ARM64 version of LLVM. By default I was getting linking errors.
You can configure CMake with below flags to enable building only arm64 libraries when you are done you should be able to use
lipo to confirm that the binaries are correct.
cmake .. -G Ninja -DCMAKE_OSX_ARCHITECTURES=arm64
For some reason using
ctypes causes an allocator segfault using the version of Python bundled by Conda and most recent Big Sur. If you instead install
cython and run
make cython in the root directory of TVM everything works as expected and you can make progress.
If anyone else has refinements to this process please post below and we can try and build a working guide which can be upstreamed as docs at some point.