[macOS][M1] Building TVM on an M1 Mac

Initial Setup

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 USE_LLVM to 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.


This is awesome!!

Another cool finding: it looks like llvmdev has been supported on osx-arm64: https://anaconda.org/conda-forge/llvmdev/files. So we don’t need rosetta to translate llvm

CC @tgall_foo who may have been looking at this too.

You’re really catching up! You should post this to the Reddit or somewhere to let more people know TVM already works on M1 Mac :smiley:


I’ve been working on TVM and deps on Apple Silicon for a bit. Really the major source of frustration for which there is no initial work around is the lack of gcc for Apple Silicon. This is the most importance dependency that needs to be addressed.

The ETA is effectively next year sometime and is a direct function of who all will jump in and help out.

Maybe this would be a good lightning talk for the tvm conf?

Once GCC is in place, native MacOS via brew or other paths will be able to build quite a number of deps pretty smoothly, like numpy etc.

The other path to success is Linux within a VM on Apple Silicon. This will provide a “just works” experience however access to offload will be the interesting bit. Parallels for instance hasn’t shipped their alpha so we don’t know what that might look like, can we make use of Metal? Who knows. Virtualbox is only just talking about Apple Silicon support, far as I can tell they’ve done nothing. That is all I’ve looked into thus far.

There is as of the moment no plans to support dual boot between say Linux and MacOS on Apple Silicon.

Another path, “We” could certainly get more deps building with clang instead of gcc. This would probably be better for the sake of the universe, yet not an easy task.

I have TVM built on my Apple Silicon hardware using clang-12. I hadn’t looked at the conda route @jroesch, so pretty cool!