1 min read

Running ONNX with onnruntime on your M1 Mac

Running ONNX with onnruntime on your M1 Mac

When wanting to work with AI models on my latest Macbook Pro 2021 with M1 Architecture, I received the following error while running pip install onnxruntime:

ERROR: Could not find a version that satisfies the requirement onnxruntime>=1.10.0 (from tinx) (from versions: none)

After doing some research, this error was not unknown. But how can we now get it resolved on this Macbook? When we look at the GitHub repository of onnxruntime we can see that an OSX version is actually being released.

Luckily, PyPi has a "Test" repository as well which we should try when the normal doesn't work, as it often hosts packages that are not found on the public one yet. So we can simply run the below which will install onnxruntime. Note, that we install flatbuffers as well, since we will else encounter an error stating that it is depending on flatbuffers.

# ONNX Depends on this, so we should first install it
pip install flatbuffers

# Then we can install onnxruntime
pip install -i https://test.pypi.org/simple/ onnxruntime

If we now run the below, we will see the onnxruntime printed and we will be able to infer AI models on our Macbook.

import onnxruntime as rt