Handle --gpus flag using CDI#4617
Merged
Merged
Conversation
AkihiroSuda
reviewed
Nov 26, 2025
Member
There was a problem hiding this comment.
Thanks, does this need any change on https://github.com/containerd/nerdctl/blob/main/docs/gpu.md ?
Contributor
Author
There was a problem hiding this comment.
I have updated this as well in the latest revision.
Contributor
Author
|
Yes, most likely. I will look at updating the docs too.
**Update**: Updated.
|
88c37fa to
ccdb3e6
Compare
ChengyuZhu6
approved these changes
Nov 27, 2025
Member
ChengyuZhu6
left a comment
There was a problem hiding this comment.
LGTM. I have tested on my machine, and it works.
AkihiroSuda
reviewed
Nov 27, 2025
| nerdctl run -it --rm --gpus 'device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a' nvidia/cuda:12.3.1-base-ubuntu20.04 nvidia-smi | ||
| ``` | ||
|
|
||
| Note that although `capabilities` options may be provided, these are ignored when processing the GPU request. |
Member
There was a problem hiding this comment.
Suggested change
| Note that although `capabilities` options may be provided, these are ignored when processing the GPU request. | |
| Note that although `capabilities` options may be provided, these are ignored when processing the GPU request since nerdctl v2.3. |
AkihiroSuda
reviewed
Nov 27, 2025
| - `nvidia-container-cli` | ||
| - containerd relies on this CLI for setting up GPUs inside container. You can install this via [`libnvidia-container` package](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/arch-overview.html#libnvidia-container). | ||
| - The NVIDIA Container Toolkit | ||
| - containerd relies on the NVIDIA Container Toolkit to make GPUs usable inside a container. You can install the NVIDIA Container Toolkit by following the [official installation instructions](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). |
Member
There was a problem hiding this comment.
Add something like
Suggested change
| - containerd relies on the NVIDIA Container Toolkit to make GPUs usable inside a container. You can install the NVIDIA Container Toolkit by following the [official installation instructions](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). | |
| - containerd relies on the NVIDIA Container Toolkit to make GPUs usable inside a container. You can install the NVIDIA Container Toolkit by following the [official installation instructions](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html). | |
| > [!NOTE] | |
| > The description in this section applies to nerdctl v2.3 or later. | |
| > Users of prior releases of nerdctl should refer to <https://github.com/containerd/nerdctl/blob/v2.2.0/docs/gpu.md> |
Member
There was a problem hiding this comment.
Maybe the note should be rather moved to the top of the documentation
Contributor
Author
There was a problem hiding this comment.
Yes, I think moving this up would be clearer.
Member
|
This PR can fix the issue #4621 |
This change switches to using CDI to handle the --gpus flag. This removes the custom implementation that invoked the nvidia-container-cli directly. This mechanism does not align with existing implementations. Signed-off-by: Evan Lezar <elezar@nvidia.com>
f2409c1 to
d312a5d
Compare
ChengyuZhu6
approved these changes
Dec 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 change switches to using CDI to handle the --gpus flag. This removes the custom implementation that invoked the nvidia-container-cli directly. This mechanism does not align with existing implementations.
See also:
ctr: Map ctr --gpus requests to NVIDIA CDI device requests containerd#12537docker: Use cdi device driver to handle nvidia --gpus requests moby/moby#50228