Skip to main content

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​

ComponentRequirement
Python3.11 – 3.14
Operating systemLinux (x86-64, arm64, glibc ≥ 2.28), macOS ≥ 14 (Apple silicon)
C++ compilerLinux: clang++-21 from the official LLVM repository; macOS: Xcode Command Line Tools
OpenMP on macOSbrew install libomp
NVIDIA GPUsCUDA toolkit in /usr/local/cuda and CuPy (cupy-cuda12x), only for target="cuda"
AMD GPUsROCm 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​

  1. On Linux, install Clang 21:

    wget https://apt.llvm.org/llvm.sh
    chmod +x llvm.sh
    sudo ./llvm.sh 21
  2. Install the docc-compiler package, preferably in a virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install docc-compiler
  3. 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.