Manage NVIDIA GPU slots in local executor #5850
Draft
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.
Experimenting with GPU slots for the local executor.
When a pipeline runs multiple GPU-enabled tasks on the same node, each task will see all GPUs and will not try to coordinate which task should use which GPU.
NVIDIA provides the
CUDA_VISIBLE_DEVICES
/NVIDIA_VISIBLE_DEVICES
environment variables to control which tasks can see which GPUs, and users generally have to manage this variable themselves. Some HPC schedulers can assign this variable automatically, or use cgroups to control GPU visibility at a lower level.Nextflow should be able to manage this variable for the local executor, so that the user doesn't have to add complex pipeline logic to do the same. Running a GPU workload locally on a multi-GPU node is a common use case, so it might be worth doing.
To use this feature, set
executor.gpus
in your config to the total number of available GPUs. Then Nextflow will automatically set theCUDA_VISIBLE_DEVICES
for each task based on theaccelerator
directive.To use with containers, you might have to add
CUDA_VISIBLE_DEVICES
todocker.envWhitelist
.CUDA_VISIBLE_DEVICES
works with containers or if you have to setNVIDIA_VISIBLE_DEVICES
.--gpus
for the docker command in order to use the GPUs at all, that can be set indocker.runOptions
See also: #5570