Installation#
Native execution uses an NVIDIA CUDA GPU. The portable PyTorch backend also supports CPU, PyTorch ROCm and Apple Silicon (MPS) devices; see Precision, training and reconstruction for precision and hardware-validation limits.
diffct needs Python 3.10 or newer, and a Python version for which PyTorch publishes wheels. Install PyTorch for your device first. Then print the CUDA version of your PyTorch build:
python -c "import torch; print(torch.version.cuda)"
Install diffct with the extra that matches this version. The extra installs the CUDA compiler libraries that Numba CUDA needs.
pip install "diffct[cu13]"
pip install "diffct[cu12]"
pip install diffct
Use backend="torch". Importing diffct and using this backend require
no CUDA runtime.
git clone https://github.com/sypsyp97/diffct.git cd diffct pip install -e ".[cu13]" # or ".[cu12]", or "." without CUDA python examples/quickstart.py
Most scripts in examples/ need an NVIDIA GPU; plot_trajectory.py
and benchmark_trajectory_admission.py --backend torch run on CPU.
Check the installation:
python -c "import torch, diffct; print(diffct.__version__); print(torch.cuda.is_available())"
Numba CUDA initializes on native use. The NVVM and NVJitLink packages must match
the CUDA libraries that PyTorch loads, so the extra must match
torch.version.cuda. A plain pip install diffct also works for native
execution if a matching CUDA Toolkit is already installed.
Troubleshooting#
CUDA is unavailable: check that the active Python environment has a CUDA build of PyTorch and that the GPU is visible to the process.
NumPy 2.5 compatibility: Numba CUDA imports
numpy.row_stack, which NumPy 2.5 removes. Keepnumpy<2.5until Numba CUDA no longer needs it.Kernel compilation fails: use Numba CUDA, NVVM and NVJitLink versions that match each other. Do not upgrade only one of them.
nvJitLink error:
nvJitLinkErrorwith “may need newer version of nvJitLink library” means that the diffct extra does not match the CUDA version of PyTorch. Printtorch.version.cudaand reinstall withdiffct[cu12]for 12.x ordiffct[cu13]for 13.x.
Tested CUDA combinations#
CUDA 13:
pip install "numpy<2.5" "numba-cuda[cu13]" "cuda-toolkit[cccl,cudart,nvrtc,nvvm]==13.0.2" "nvidia-nvjitlink<13.1"CUDA 12: PyTorch 2.10 (cu126) with
numba-cuda[cu12]0.30.4 on NVIDIA driver 535.