- CUDA ≥ 12.6 supported GPU (optional, but recommended for training).
- Linux, macOS, or Windows with Python ≥ 3.12.
- PyTorch ≥ 2.11.
- Only required when building from source (prebuilt wheels are published to
PyPI): a working C++20 compiler. The build uses
meson-pythonwith Meson andninja, both of which are installed automatically as build dependencies.nanobindis fetched and compiled from a pinned Meson subproject, so no separate install is needed.
uv is the recommended way to install DIRECT
for both users and developers. It produces fast, reproducible environments
directly from pyproject.toml and the committed uv.lock.
Install
uvfollowing the official instructions.Clone the repository and synchronise the environment.
DIRECTis built without build isolation (so the editable install can rebuild the C++ extensions on the fly using the environment's ownninja), which means the build tooling must be installed before the project. Runuv synctwice:git clone https://github.com/NKI-AI/direct.git cd direct uv sync --no-install-project # runtime + dev + build tooling uv sync # build & install DIRECT itself uv sync --all-groups # (optional) also install docs tooling
uvwill provision Python 3.12, create.venv/, build the C++ extensions viameson-python+nanobind, and install all pinned dependencies fromuv.lock. The two-step sync keeps the editable install pointed at the persistent.venvninja instead of a throwaway build environment, so imports keep working afteruvprunes its cache.Either activate the environment or prefix commands with
uv run:source .venv/bin/activate direct --help
uv run direct --help uv run pytest
DIRECT is published to PyPI as direct-recon (the import package is still
direct). On the supported platforms this fetches a prebuilt wheel (abi3
on Linux/macOS, Python-version-specific on Windows), so nothing is compiled:
pip install direct-recon
import directIf no wheel is available for your platform, pip builds the C++ extensions
from the source distribution via meson-python + nanobind in an isolated
build environment; only a working C++20 compiler is required. The conda section
below shows a step-by-step build, including installing PyTorch with CUDA first.
For an editable/development install, install the build tooling first and disable build isolation so the on-import rebuild keeps working:
pip install meson-python meson ninja pip install --no-build-isolation -e .
We provide a Dockerfile
which installs DIRECT with a few commands. Recommended when you need a
fully reproducible CUDA stack.
Install conda. Here is a guide on how to install conda on Linux if you don't already have it here. Once you have conda, create a Python 3.12 conda environment:
conda create -n myenv python=3.12
Then activate the virtual environment
myenvyou created where you will install the software:conda activate myenv
If you are using GPUs, CUDA is required for the project to run. To install PyTorch with CUDA run (adjust the index URL for your CUDA version):
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126
otherwise, install the latest PyTorch CPU version (not recommended):
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu
Install
DIRECTfrom PyPI. On the supported platforms this fetches a prebuilt wheel (abi3on Linux/macOS, Python-version-specific on Windows), so nothing is compiled:pip3 install direct-recon
To build from a checkout instead, clone the repository, navigate to
direct/and runpython3 -m pip install .
pipbuilds the C++ extensions automatically viameson-python+nanobindin an isolated build environment; only a working C++20 compiler is required.For an editable install, first install the build tooling into the active environment and disable build isolation so the on-import rebuild keeps working:
python3 -m pip install meson-python meson ninja python3 -m pip install --no-build-isolation -e .
Development and documentation dependencies are declared as PEP 735
[dependency-groups]inpyproject.toml. Withpip≥ 25.1 you can install them withpip install --group dev/--group docs; otherwise use theuvpath above.
If you met issues using DIRECT, please first update the repository to the latest version, and rebuild the docker. When this does not work, create a GitHub issue so we can see whether this is a bug, or an installation problem.