Skip to content

Instantly share code, notes, and snippets.

@cansik
Created June 1, 2022 22:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cansik/e403925353bb72c38892b06d4aa8a52c to your computer and use it in GitHub Desktop.
Save cansik/e403925353bb72c38892b06d4aa8a52c to your computer and use it in GitHub Desktop.
Computer Vision with Python on M1 Apple Silicon (arm64)

Computer Vision with Python on M1 Apple Silicon (arm64)

When switching over to a new MacBook with an M1 Apple Silicon chip, I noticed that many python packages I use daily are not compatible with M1 chips. Sometimes there was just no prebuilt wheel, or there were still bugs in the code not allowing the package to build at all. So I decided to create drop-in replacement packages with prebuilt wheels for the Apple Mac M1 (Apple Silicon / arm64).

Every package contains a build script to automatically build it in your own enviroment and a Github CI workflow to build it on Github (if possible).

Here you find a list of all the prebuilt packages. Sometimes the official maintainer have updated their binaries too, so please first check if there is an official build ready for M1.

A librealsense2 python wrapper built for all modern MacOSX versions (intel / silicon) because Intel does only support MacOS High Sierra officially. This build runs on M1 but it could be that you have to run your script with sudo.

Installation

pip install pyrealsense2-macosx

For requirements.txt files use the following snippet:

pyrealsense2; platform_system == "Windows" or platform_system == "Linux"
pyrealsense2-macosx; platform_system == "Darwin"

The onnxruntime is ready to be built on MacOS M1 but there are no PyPi hosted packages at the moment. So I prebuilt the wheels and published them. This is currently not built with ML Core support.

Installation

pip install onnxruntime-silicon

For requirements.txt files use the following snippet:

onnxruntime; platform_system == "Windows" or platform_system == "Linux"
onnxruntime; platform_system == "Darwin" and platform.machine != "arm64"
onnxruntime-silicon; platform_system == "Darwin" and platform.machine == "arm64"

Prebuilt openvino python package with the openvino arm cpu extension for MacOS. In comparison to the other packages, this one does not contain all the features the official package offers. It is a special build and only supports FP32 models.

Installation

pip install openvino-arm

For requirements.txt files use the following snippet:

openvino; platform_system == "Windows" or platform_system == "Linux"
openvino; platform_system == "Darwin" and platform.machine != "arm64"
openvino-arm; platform_system == "Darwin" and platform.machine == "arm64"

Google MediaPipe prebuilt for M1 which runs perfectly fine on a Mac M1 (reaching 24 FPS for pose detection with ease).

Installation

pip install mediapipe-silicon

For requirements.txt files use the following snippet:

mediapipe; platform_system == "Windows" or platform_system == "Linux"
mediapipe;  platform_system == "Darwin" and platform.machine != "arm64"
mediapipe-silicon; platform_system == "Darwin" and platform.machine == "arm64"

About

MIT License - Copyright (c) 2022 Florian Bruggisser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment