Skip to main content

Install docc for PyTorch

docc plugs into PyTorch as a torch.compile backend. You keep your model as it is, add one import, and select backend="docc". In this Quickstart, you install the backend and then run an image classifier (ResNet-18) on all CPU cores and on a GPU.

Requirements​

ComponentRequirement
Python3.11 – 3.14
Operating systemLinux (x86-64, arm64), macOS ≥ 14 (Apple silicon, CPU only)
PyTorch2.13 (the tested version)
C++ compilerLinux: clang++-21 from the official LLVM repository; macOS: Xcode Command Line Tools
NVIDIA GPUsCUDA 12 and CuPy (cupy-cuda12x)
AMD GPUsROCm 7 and CuPy (cupy-rocm-7-0)

The backend generates C++ code for your model and compiles it with Clang, which 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. Create a virtual environment and install PyTorch for your hardware:

    python3 -m venv .venv
    source .venv/bin/activate

    # CPU only
    pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
    # NVIDIA GPUs (use cu129 for Blackwell GPUs such as RTX 50xx and B200)
    pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126 && pip install cupy-cuda12x
    # AMD GPUs
    pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.2 && pip install cupy-rocm-7-0
  3. Install the docc compiler and the PyTorch backend:

    pip install docc-compiler docc-pytorch
  4. Check the installation:

    python -c "import docc.pytorch; print('docc backend 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 Model to compile and accelerate ResNet-18.