Updating GPU (accelerator) support in MLCube. #351
Merged
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.
This commit changes how MLCube runtime works with GPUs. Users have two options to provide information on required accelerators:
platform
section (platform.accelerator_count). This value is optional, and if present, may be an empy / non-set string, or an integer. This values is the number of required accelerators, and semantically, is equivalent to docker's--gpu=N
CLI argument.--gpus
argument, e.g.,mlcube run ... --gpus=4
. This parameter accepts same values as docker's--gpus
CLI argument does. Concretely:--gpus=
) to disable GPUs, all (--gpus=all
) to use all available GPUs, GPU count (--gpus=N
) or list of concrete GPUs (--gpus="device=0,2"
). In this list GPU indices or UUIDs can be used.Docker runner will pretty much use this value unmodified and will pass it to docker run command, e.g.,
--gpus
flag will present. Singularity runner will pass--nv
command when GPUs are requested. No CUDA_VISIBLE_DEVICES, SINGULARITYENV_CUDA_VISIBLE_DEVICES or any other env variable will be set by MLCube runtime (docker NVIDIA runtime may set NVIDIA_VISIBLE_DEVICES).To debug for possble issues, enable debug mode (e.g.,
mlcube --log-level=debug run ...
) and search the output for the log lines that containDEBUG Device spec (...) resolved to ...
andINFO Device params ... resolved to ...
. They will provide additional information on how MLCube runtime determines how GPUs should be used.