This guide consolidates the setup steps needed for a first nnU-Net v2 run.
- Use Python 3.10 or newer.
- Linux is the primary target, but Windows and macOS are also supported.
- GPU is strongly recommended for training.
- Apple
mpscan be used, but 3D convolutions may still require CPU fallback.
Install PyTorch for your hardware before installing nnunetv2:
https://pytorch.org/get-started/locally/
Choose the build that matches your environment:
cudafor NVIDIA GPUsmpsfor Apple Siliconcpuif no accelerator is available
Do not install nnunetv2 before PyTorch is in place.
For normal use:
pip install nnunetv2If you want a local editable checkout for development:
git clone https://github.com/MIC-DKFZ/nnUNet.git
cd nnUNet
pip install -e .On Intel (non-Apple-Silicon) macOS, add the intel_macos extra to pin compatible
versions of torch and numpy:
pip install "nnunetv2[intel_macos]"or with an editable install:
pip install -e ".[intel_macos]"nnU-Net needs three locations:
nnUNet_raw: raw datasets in nnU-Net formatnnUNet_preprocessed: preprocessed data used during trainingnnUNet_results: trained models and installed pretrained models
Recommended layout:
/path/to/nnUNet_raw
/path/to/nnUNet_preprocessed
/path/to/nnUNet_results
Inside nnUNet_raw, each dataset lives in its own DatasetXXX_Name folder.
Example:
nnUNet_raw/
└── Dataset001_MyDataset
├── dataset.json
├── imagesTr
├── imagesTs
└── labelsTr
For a persistent setup, add this to your shell profile such as .bashrc or .zshrc:
export nnUNet_raw="/path/to/nnUNet_raw"
export nnUNet_preprocessed="/path/to/nnUNet_preprocessed"
export nnUNet_results="/path/to/nnUNet_results"For a temporary setup, run the same commands in the current shell before using nnU-Net.
$Env:nnUNet_raw = "C:/path/to/nnUNet_raw"
$Env:nnUNet_preprocessed = "C:/path/to/nnUNet_preprocessed"
$Env:nnUNet_results = "C:/path/to/nnUNet_results"set nnUNet_raw=C:/path/to/nnUNet_raw
set nnUNet_preprocessed=C:/path/to/nnUNet_preprocessed
set nnUNet_results=C:/path/to/nnUNet_resultsCheck that the variables are visible in your shell.
Linux and macOS:
echo "$nnUNet_raw"
echo "$nnUNet_preprocessed"
echo "$nnUNet_results"PowerShell:
echo $Env:nnUNet_raw
echo $Env:nnUNet_preprocessed
echo $Env:nnUNet_resultsCommand Prompt:
echo %nnUNet_raw%
echo %nnUNet_preprocessed%
echo %nnUNet_results%hiddenlayer enables network topology plots:
pip install --upgrade git+https://github.com/FabianIsensee/hiddenlayer.gitIf you train on a fast GPU, you may also want to tune nnUNet_n_proc_DA for data augmentation throughput.