nnU-Net requires some environment variables so that it always knows where the raw data, preprocessed data and trained models are. Depending on the operating system, these environment variables need to be set in different ways.
Variables can either be set permanently (recommended!) or you can decide to set them every time you call nnU-Net.
Locate the .bashrc
file in your home folder and add the following lines to the bottom:
export nnUNet_raw="/media/fabian/nnUNet_raw"
export nnUNet_preprocessed="/media/fabian/nnUNet_preprocessed"
export nnUNet_results="/media/fabian/nnUNet_results"
(Of course you need to adapt the paths to the actual folders you intend to use).
If you are using a different shell, such as zsh, you will need to find the correct script for it. For zsh this is .zshrc
.
Just execute the following lines whenever you run nnU-Net:
export nnUNet_raw="/media/fabian/nnUNet_raw"
export nnUNet_preprocessed="/media/fabian/nnUNet_preprocessed"
export nnUNet_results="/media/fabian/nnUNet_results"
(Of course you need to adapt the paths to the actual folders you intend to use).
Important: These variables will be deleted if you close your terminal! They will also only apply to the current terminal window and DO NOT transfer to other terminals!
Alternatively you can also just prefix them to your nnU-Net commands:
nnUNet_results="/media/fabian/nnUNet_results" nnUNet_preprocessed="/media/fabian/nnUNet_preprocessed" nnUNetv2_train[...]
You can always execute echo ${nnUNet_raw}
etc to print the environment variables. This will return an empty string if
they were not set.
Useful links:
See Set Environment Variable in Windows via GUI
here.
Or read about setx (command prompt).
Just execute the following before you run nnU-Net:
(PowerShell)
$Env:nnUNet_raw = "C:/Users/fabian/nnUNet_raw"
$Env:nnUNet_preprocessed = "C:/Users/fabian/nnUNet_preprocessed"
$Env:nnUNet_results = "C:/Users/fabian/nnUNet_results"
(Command Prompt)
set nnUNet_raw=C:/Users/fabian/nnUNet_raw
set nnUNet_preprocessed=C:/Users/fabian/nnUNet_preprocessed
set nnUNet_results=C:/Users/fabian/fabian/nnUNet_results
(Of course you need to adapt the paths to the actual folders you intend to use).
Important: These variables will be deleted if you close your session! They will also only apply to the current window and DO NOT transfer to other sessions!
Printing in Windows works differently depending on the environment you are in:
PowerShell: echo $Env:[variable_name]
Command Prompt: echo %[variable_name]%