Installing unigpu on Linux¶
| Hardware | Backends |
|---|---|
| no GPU | sim; opencl on every core of the CPU (POCL) |
| NVIDIA GPU | cuda; opencl on the same GPU |
| AMD GPU | hip (ROCm); opencl on the same GPU |
| Intel GPU, integrated or Arc | opencl |
The general steps are explained in INSTALL.md. The
commands below are for Debian and Ubuntu; for Fedora, replace
sudo apt install by sudo dnf install.
1. Python and git¶
sudo apt install python3 python3-venv python3-pip git
python3 --version # 3.10 or newer
Ubuntu 22.04 provides Python 3.10, Ubuntu 24.04 Python 3.12, Debian 12 Python 3.11: all of them work.
2. Code and virtual environment¶
git clone https://github.com/laveneau/unigpu.git
cd unigpu
python3 -m venv .venv
source .venv/bin/activate # again in every new terminal
python -m pip install --upgrade pip
pip install -e . # the simulator: enough to start
Without git: see INSTALL.md.
3. Your hardware¶
No GPU¶
pip install -e ".[opencl-cpu]" # POCL: OpenCL on every core of the CPU
POCL is distributed by pip for x86-64 processors only (uname -m prints
x86_64). On an ARM machine (aarch64: Raspberry Pi, ARM Chromebook or
server), install the POCL of the distribution instead:
sudo apt install pocl-opencl-icd
pip install -e ".[opencl]"
NVIDIA GPU¶
- Install the NVIDIA driver of the distribution (on Ubuntu:
sudo ubuntu-drivers install), then restart.nvidia-smimust show the GPU and, at the top right,CUDA Version: 12.0or newer. -
Install the CUDA backend:
pip install -e ".[cuda]"numba-cuda brings the CUDA libraries it needs: there is no CUDA toolkit to install. If
nvidia-smishowsCUDA Version: 13.0or newer, thecuda13option installs those of CUDA 13 instead:pip install -e ".[cuda13]". CUDA 13 needs a GPU from the Turing generation (GeForce 16 and RTX 20) or newer. -
Optionally, OpenCL on the same GPU (to compare the backends):
pip install -e ".[opencl]"The driver provides the OpenCL library (
libnvidia-opencl.so.1). If no "NVIDIA CUDA" OpenCL platform appears, declare it:sudo mkdir -p /etc/OpenCL/vendors echo libnvidia-opencl.so.1 | sudo tee /etc/OpenCL/vendors/nvidia.icd
AMD GPU¶
-
Install ROCm by following AMD's guide (on Ubuntu, with
amdgpu-install). Then give yourself access to the GPU, and log out and back in:sudo usermod -a -G render,video $LOGNAMErocminfomust list the GPU (agfx...name). -
The HIP backend, compiled by numba-hip:
pip install -e ".[hip]"numba-hip requires numba < 0.64: give it its own virtual environment if another one uses the
cudaoption. It does not provide atomics on arrays, dynamic shared memory,print()in a kernel norfloat16; unigpu says so. -
OpenCL on the same GPU, which also supports these features: install ROCm's OpenCL runtime (
amdgpu-install --usecase=opencl), then:pip install -e ".[opencl]"
Without ROCm, for instance for integrated Radeon graphics, Mesa's OpenCL
driver can be used: sudo apt install mesa-opencl-icd, then run the
programs with RUSTICL_ENABLE=radeonsi.
Intel GPU¶
sudo apt install intel-opencl-icd # Fedora: sudo dnf install intel-compute-runtime
pip install -e ".[opencl]"
Many Intel GPUs have no double precision. unigpu then treats Python floats
as float32, and 00_discovery.py shows float64: no. Mesa's OpenCL driver
works too: mesa-opencl-icd, with RUSTICL_ENABLE=iris.
4. Check¶
python -m unigpu.selftest all
python examples/00_discovery.py
Every device must end with 11/11 checks passed. Optionally, clinfo
(sudo apt install clinfo) lists the OpenCL platforms that the system sees,
independently of unigpu.
Problems¶
| In "Unavailable backends" or in the error | What to do |
|---|---|
opencl: PyOpenCL is not installed |
pip install -e ".[opencl]" (or [opencl-cpu]) |
opencl: no OpenCL driver installed |
install the OpenCL driver of the hardware (above); each driver puts a file in /etc/OpenCL/vendors |
cuda: numba-cuda is not installed |
pip install -e ".[cuda]", in the activated environment |
cuda: CUDA unusable, or no GPU detected by the driver |
nvidia-smi must work: driver missing or too old, or restart needed |
hip: numba-hip is not installed |
pip install -e ".[hip]", on a machine with ROCm |
hip: ROCm unusable |
rocminfo must list the GPU; check the render and video groups |
pip refuses to install outside an environment (externally-managed-environment) |
activate the virtual environment first (source .venv/bin/activate) |