Installing unigpu on macOS¶
| Hardware | Backends |
|---|---|
| Mac with Apple Silicon (M1 to M4...) | metal, sim |
| Mac with an Intel processor (and its Intel or AMD GPU) | metal, sim |
| either, optionally | opencl through conda (below) |
CUDA and HIP do not exist on macOS. The Metal backend uses the GPU of every Mac: it is the one to install. The general steps are explained in INSTALL.md.
The Metal backend works on an iPad, through rubicon-objc. On a Mac, its PyObjC path has been checked against PyObjC's sources but not run yet: please send the output of the check (step 4).
1. Python and git¶
Install Python 3.12 from python.org,
or with Homebrew: brew install python@3.12. The
python3 of Apple's command line tools (Python 3.9) also works, with older
versions of the packages.
Git comes with Apple's command line tools: xcode-select --install. Or use
the ZIP download below.
2. Code and virtual environment¶
In the Terminal:
git clone https://github.com/laveneau/unigpu.git
cd unigpu
python3.12 -m venv .venv
source .venv/bin/activate # again in every new terminal
python -m pip install --upgrade pip
pip install -e . # the simulator
Without git: see INSTALL.md.
3. Metal¶
pip install -e ".[metal]" # PyObjC, bridge to Apple's frameworks
Another bridge works too, in pure Python: pip install -e ".[metal-rubicon]"
(rubicon-objc, the one used on iPad). unigpu uses PyObjC if both are installed.
Metal has no double precision: unigpu treats Python floats as float32, and
refuses float64 with a clear message.
OpenCL (optional)¶
Apple's OpenCL 1.2 is deprecated and has no subgroups: the warps need Metal there. PyOpenCL 2026.1.5, installed by pip, sees it (tried with Python 3.13 on an M5 Max):
pip install pyopencl
With conda (Miniforge), POCL on the CPU should be usable too. Not tried yet:
conda create -n unigpu -c conda-forge python=3.12 numpy pyopencl ocl_icd_wrapper_apple pocl
conda activate unigpu
pip install -e .
4. Check¶
python -m unigpu.selftest all
python examples/00_discovery.py
The report must show a line Platform metal:0 — Apple Metal (Apple) via
PyObjC, with the GPU of the Mac, and each device must end with
11/11 checks passed.
Problems¶
| In "Unavailable backends" or in the error | What to do |
|---|---|
metal: no Objective-C library |
pip install -e ".[metal]" in the activated environment; the message lists what was tried |
xcrun: error: invalid active developer path when using git |
xcode-select --install |
opencl: no OpenCL driver installed |
expected with pip: see "OpenCL (optional)" |
cuda, hip: not installed |
expected on macOS |