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.

  • Kernel compilation fails: use Numba CUDA, NVVM and NVJitLink versions that match each other. Do not upgrade only one of them.

  • nvJitLink error: nvJitLinkError with “may need newer version of nvJitLink library” means that the diffct extra does not match the CUDA version of PyTorch. Print torch.version.cuda and reinstall with diffct[cu12] for 12.x or diffct[cu13] for 13.x.