New feature: adding a parameter to control the number of processes used by the validation dataloader #2053
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Many nnUNet users try to run it on systems in which the hardware is lacking (there are many users reporting
Some background worker is 6 feet under
).Currently, the validation dataloader uses half the number of processes of the training dataloader. A default training with nnUNet uses 1 main process + 12 train dataloader processes + 6 validation dataloader processes, which copy all the main's process allocated memory.
On systems with modest RAM resources, if there is enough RAM utilization during training, the validation dataloaders' memory (including the validation data that was already loaded) is moved on the swap partition because the validation dataloaders sleep and wait for the end of the training epoch, which makes the start of the validation very slow.
Reducing the number of dataloader processes (
nnUNet_n_proc_DA
) avoids OOM errors and slowdowns on systems without enough RAM memory that start to use the swap partition.New feature
Reducing the number of validation dataloader processes (with the new environment variable
nnUNet_n_proc_DA_val
) enables better resource management and allows for allocating more processes for training by reducing the processes for validation. This solution is especially useful when the default value ofnum_val_iterations_per_epoch
is changed from 50 to 10.