Install docc for Python
The docc Python package compiles Python functions that work on NumPy arrays into native code for CPUs and GPUs. You add a decorator; docc compiles the function the first time it is called. In this Quickstart, you install the package and then run the WAXPBY example on all CPU cores and on a GPU.
Requirements
| Component | Requirement |
|---|---|
| Python | 3.11 – 3.14 |
| Operating system | Linux (x86-64, arm64, glibc ≥ 2.28), macOS ≥ 14 (Apple silicon) |
| C++ compiler | Linux: clang++-21 from the official LLVM repository; macOS: Xcode Command Line Tools |
| OpenMP on macOS | brew install libomp |
| NVIDIA GPUs | CUDA toolkit in /usr/local/cuda and CuPy (cupy-cuda12x), only for target="cuda" |
| AMD GPUs | ROCm in /opt/rocm or $ROCM_PATH and CuPy (cupy-rocm-7-0), only for target="rocm" |
docc generates C++ code and compiles it with Clang when your function is called for the first time. This is why a C++ compiler is required at runtime.
Install
-
On Linux, install Clang 21:
wget https://apt.llvm.org/llvm.shchmod +x llvm.shsudo ./llvm.sh 21 -
Install the
docc-compilerpackage, preferably in a virtual environment:python3 -m venv .venvsource .venv/bin/activatepip install docc-compiler -
Check the installation:
python -c "from docc.python import native; print('docc is ready')"
Prepare GPU targets (optional)
docc detects the first GPU in your system and compiles for its architecture. To select a different one, set:
export DOCC_CUDA_ARCH=sm_90 # NVIDIA H100
export DOCC_ROCM_ARCH=gfx942 # AMD MI300
Next step
Continue with Run Your First Code to compile and accelerate the WAXPBY example.