Container Device Interface (CDI) and Node Resource Interface (NRI) Plugin Support#
This page gives an overview of CDI and NRI Plugin support in the GPU Operator.
About Container Device Interface (CDI)#
The Container Device Interface (CDI) is an open specification for container runtimes that abstracts what access to a device, such as an NVIDIA GPU, means, and standardizes access across container runtimes. Popular container runtimes can read and process the specification to ensure that a device is available in a container. CDI simplifies adding support for devices such as NVIDIA GPUs because the specification is applicable to all container runtimes that support CDI.
Starting with GPU Operator v25.10.0, container runtimes such as containerd and CRI-O process CDI specifications to make GPUs available inside workload containers.
In earlier GPU Operator releases, enabling CDI relied on the NVIDIA container runtime to process CDI specifications.
The NVIDIA container runtime was available through a CDI-enabled nvidia runtime class.
In GPU Operator releases prior to v25.10.0, CDI was disabled by default.
Before upgrading from one of these releases to v25.10.0 or later, review the existing configuration as described in Before Enabling CDI or Upgrading.
For workloads using GPU allocation through the Device Plugin, no configuration changes are required if you use the Operator’s default device-list and container-toolkit settings.
GPU access for these workloads uses the container runtime’s CDI support, so runtimeClassName: nvidia is optional.
With these default settings, existing workloads can retain runtimeClassName: nvidia if the nvidia runtime class is available in the cluster.
Use of CDI is transparent to cluster administrators and application developers. The benefits of CDI are largely to reduce development and support for runtime-specific plugins.
NVIDIA Container Toolkit provides tools and libraries for generating CDI specifications for NVIDIA GPUs. Refer to the Support for Container Device Interface page for more information on using CDI.
CDI and GPU Management Containers#
When you enable CDI in GPU Operator v25.10.0 or later, GPU Management Containers that use the NVIDIA_VISIBLE_DEVICES environment variable to get GPU access, bypassing GPU allocation via the Device Plugin or DRA Driver for GPUs, must set runtimeClassName: nvidia in the pod specification.
A GPU Management Container is a container that requires access to all GPUs without them being allocated by Kubernetes.
Examples of GPU Management Containers include monitoring agents and device plugins.
NVIDIA recommends using NVIDIA_VISIBLE_DEVICES for GPU Management Containers only.
Note
Setting runtimeClassName: nvidia in the pod specification is not required when the NRI Plugin is enabled in GPU Operator.
Refer to About the Node Resource Interface (NRI) Plugin.
CDI and Device List Settings#
When Kubernetes allocates a GPU to a workload, the NVIDIA Device Plugin passes information about that GPU to the container runtime. The runtime uses this information to make the GPU available inside the container. The method used to pass the GPU information is called a device-list strategy.
With CDI enabled, the device plugin identifies GPUs by using names that refer to CDI device specifications. These specifications describe the device files, libraries, and other settings needed to provide GPU access.
NVIDIA recommends using the GPU Operator’s default device-list settings when CDI is enabled.
The Operator configures these settings automatically.
You do not need to set DEVICE_LIST_STRATEGY.
The DEVICE_LIST_STRATEGY environment variable controls how the device plugin communicates GPU allocations to the container runtime.
The Operator’s default value with CDI enabled, cdi-cri,cdi-annotations, enables two delivery methods:
cdi-cripasses CDI device names through theCDIDevicesfield of the Container Runtime Interface (CRI), the API Kubernetes uses to communicate with the container runtime. Both Kubernetes and the container runtime must support this field.cdi-annotationspasses the same names through container metadata called annotations. This strategy provides another delivery method when support for the dedicated field is unavailable. The container runtime must support CDI annotations.
When both strategies are enabled, the device plugin communicates the same allocation through both methods. Specifying both strategies does not allocate additional GPUs.
Before Enabling CDI or Upgrading#
For an existing installation, review the current cluster policy before enabling CDI. This review also applies when upgrading from GPU Operator releases prior to v25.10.0, where CDI was disabled by default, to v25.10.0 or later. Check for device-list and container-toolkit overrides that can interfere with CDI.
The cluster policy stores the configuration used by the GPU Operator. The following commands inspect the cluster policy without changing the cluster.
Find the cluster policy name:
$ kubectl get clusterpolicies.nvidia.comThe name is typically
cluster-policy.Display the configuration, replacing
<policy-name>with the name returned above:$ kubectl get clusterpolicies.nvidia.com <policy-name> -o yamlLook for the following environment-variable entries:
DEVICE_LIST_STRATEGYunderspec.devicePlugin.env. A value supplied here overrides the Operator’s default.ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTSunderspec.toolkit.env. This setting controls whether the NVIDIA runtime interprets special device-list mounts as GPU requests. This setting does not affect ordinary application volume mounts.
For example, the following configuration contains settings to fix before enabling CDI:
spec: devicePlugin: env: - name: DEVICE_LIST_STRATEGY value: volume-mounts toolkit: env: - name: ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTS value: "true"
Update the environment variables only if they contain legacy settings:
Device-list strategy: If
DEVICE_LIST_STRATEGYincludesenvvarorvolume-mounts, remove the entry to use the Operator’s defaults when CDI is enabled. If you prefer an explicit value, setDEVICE_LIST_STRATEGYtocdi-cri,cdi-annotations.Mount acceptance: If
ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTSis"true", remove the entry or set its value to"false".
If neither condition applies, leave the environment-variable settings unchanged.
Enabling CDI#
CDI is enabled by default during installation in GPU Operator v25.10.0 and later. Follow the instructions for installing the Operator with Helm on the Installing the NVIDIA GPU Operator page.
CDI is also enabled by default during a Helm upgrade to GPU Operator v25.10.0 and later. Before upgrading an existing installation, complete the review in Before Enabling CDI or Upgrading.
Enabling CDI After Installation#
CDI is enabled by default in GPU Operator v25.10.0 and later. Use the following procedure to enable CDI if you disabled CDI during installation.
Procedure
Enable CDI by modifying the cluster policy:
$ kubectl patch clusterpolicies.nvidia.com/cluster-policy --type='json' \ -p='[{"op": "replace", "path": "/spec/cdi/enabled", "value":true}]'
Example Output
clusterpolicy.nvidia.com/cluster-policy patchedOptional: Confirm that the container toolkit and device plugin pods restart:
$ kubectl get pods -n gpu-operatorExample Output
NAME READY STATUS RESTARTS AGE gpu-feature-discovery-qnw2q 1/1 Running 0 47h gpu-operator-6d59774ff-hznmr 1/1 Running 0 2d gpu-operator-node-feature-discovery-master-6d6649d597-7l8bj 1/1 Running 0 2d gpu-operator-node-feature-discovery-worker-v86vj 1/1 Running 0 2d nvidia-container-toolkit-daemonset-2768s 1/1 Running 0 2m11s nvidia-cuda-validator-ls4vc 0/1 Completed 0 47h nvidia-dcgm-exporter-fxp9h 1/1 Running 0 47h nvidia-device-plugin-daemonset-dvp4v 1/1 Running 0 2m26s nvidia-device-plugin-validator-kvxbs 0/1 Completed 0 47h nvidia-driver-daemonset-m86r7 1/1 Running 0 2d nvidia-operator-validator-xg98r 1/1 Running 0 47h
Disabling CDI#
While CDI is the default and recommended mechanism for injecting GPU support into containers, you can disable CDI and use the legacy NVIDIA Container Toolkit stack instead with the following procedure:
If your nodes use the CRI-O container runtime, then temporarily disable the GPU Operator validator:
$ kubectl label nodes \ nvidia.com/gpu.deploy.operator-validator=false \ -l nvidia.com/gpu.present=true \ --overwrite
Tip
You can run
kubectl get nodes -o wideand view theCONTAINER-RUNTIMEcolumn to determine if your nodes use CRI-O.Disable CDI by modifying the cluster policy:
$ kubectl patch clusterpolicies.nvidia.com/cluster-policy --type='json' \ -p='[{"op": "replace", "path": "/spec/cdi/enabled", "value":false}]'
Example Output
clusterpolicy.nvidia.com/cluster-policy patchedIf you temporarily disabled the GPU Operator validator, re-enable the validator:
$ kubectl label nodes \ nvidia.com/gpu.deploy.operator-validator=true \ nvidia.com/gpu.present=true \ --overwrite
Troubleshooting CDI#
Combining the volume-mounts device-list strategy with ACCEPT_NVIDIA_VISIBLE_DEVICES_AS_VOLUME_MOUNTS=true can prevent GPU containers from starting when they use the NVIDIA container runtime in CDI mode.
This runtime can be selected through runtimeClassName: nvidia or through the node’s default runtime configuration.
Pod events can contain an error similar to the following example:
failed to inject CDI devices: unresolvable CDI devices management.nvidia.com/gpu=GPU-<uuid>
The volume-mounts strategy encodes allocated GPU identifiers in special device-list mounts.
These identifiers do not include a CDI kind, so the NVIDIA runtime uses the Operator-configured default kind, management.nvidia.com/gpu.
That kind contains only the device named all, so individual GPU identifiers cannot resolve through this mechanism.
Additional CDI device-list strategies do not prevent this failure when the NVIDIA runtime also processes the device-list mounts.
To resolve this error, restore the recommended settings described in Before Enabling CDI or Upgrading.
About the Node Resource Interface (NRI) Plugin#
Note
The containerd project has not yet released a general availability (GA) version of the NRI Plugin. The implementation might change before the GA release. Refer to the containerd NRI repository for details on project details.
Node Resource Interface (NRI) is a standardized interface for plugging in extensions, called NRI Plugins, to OCI-compatible container runtimes like containerd. NRI Plugins serve as hooks which intercept pod and container lifecycle events and perform functions including injecting devices to a container, topology aware placement strategies, and more. For more details on NRI, refer to the NRI overview in the containerd repository.
When enabled in the GPU Operator, the NVIDIA Container Toolkit daemonset will run an NRI Plugin on every GPU node.
The purpose of the NRI Plugin is to inject GPUs into GPU management containers that use the NVIDIA_VISIBLE_DEVICES environment variable to get GPU access, bypassing GPU allocation via the Device Plugin or DRA Driver for GPUs.
In previous GPU Operator versions, device injection was handled by the nvidia container runtime. With CDI and the NRI Plugin enabled, the nvidia runtime class is no longer needed. When enabling the NRI plugin during install, the nvidia runtime class will not be created. If you enable the NRI Plugin after install, the nvidia runtime class will be deleted.
Additionally, with the NRI Plugin enabled, modifications to the container runtime configuration are no longer needed. For example, no modifications are made to containerd’s config.toml file.
This means that on platforms that configure containerd in a non-standard way, like k3s, k0s, and Rancher Kubernetes Engine 2, users no longer need to configure environment variables like CONTAINERD_CONFIG, CONTAINERD_SOCKET, or RUNTIME_CONFIG_SOURCE.
Enabling the NRI Plugin#
The NRI Plugin requires the following:
CDI to be enabled in the GPU Operator.
One of the following container runtimes:
containerd v1.7.30, v2.1.x, v2.2.x, or v2.3.x.
cri-o v1.34 or later.
If you are not using the latest containerd runtime version, check that both CDI and NRI are enabled in the runtime’s configuration file before deploying GPU Operator.
To enable the NRI Plugin during installation, follow the instructions for installing the Operator with Helm on the Installing the NVIDIA GPU Operator page and include the --set cdi.nriPluginEnabled=true argument in your Helm command.
Enabling the NRI Plugin After Installation#
Enable NRI Plugin by modifying the cluster policy:
$ kubectl patch clusterpolicies.nvidia.com/cluster-policy --type='json' \ -p='[{"op": "replace", "path": "/spec/cdi/nriPluginEnabled", "value":true}]'
Example Output
clusterpolicy.nvidia.com/cluster-policy patchedAfter enabling the NRI Plugin, the
nvidiaruntime class will be deleted.(Optional) Confirm that the container toolkit and device plugin pods restart:
$ kubectl get pods -n gpu-operatorExample Output
NAME READY STATUS RESTARTS AGE gpu-feature-discovery-qnw2q 1/1 Running 0 47h gpu-operator-6d59774ff-hznmr 1/1 Running 0 2d gpu-operator-node-feature-discovery-master-6d6649d597-7l8bj 1/1 Running 0 2d gpu-operator-node-feature-discovery-worker-v86vj 1/1 Running 0 2d nvidia-container-toolkit-daemonset-2768s 1/1 Running 0 2m11s nvidia-cuda-validator-ls4vc 0/1 Completed 0 47h nvidia-dcgm-exporter-fxp9h 1/1 Running 0 47h nvidia-device-plugin-daemonset-dvp4v 1/1 Running 0 2m26s nvidia-device-plugin-validator-kvxbs 0/1 Completed 0 47h nvidia-driver-daemonset-m86r7 1/1 Running 0 2d nvidia-operator-validator-xg98r 1/1 Running 0 47h
Disabling the NRI Plugin#
Disable the NRI Plugin and use the nvidia runtime class instead with the following procedure:
Disable the NRI Plugin by modifying the cluster policy:
$ kubectl patch clusterpolicies.nvidia.com/cluster-policy --type='json' \
-p='[{"op": "replace", "path": "/spec/cdi/nriPluginEnabled", "value":false}]'
Example Output
clusterpolicy.nvidia.com/cluster-policy patched
After disabling the NRI Plugin, the nvidia runtime class will be created.
Requesting CDI Devices with the NRI Plugin#
When the NRI Plugin is enabled, a pod can request that the NRI Plugin inject specific CDI devices into one of its containers. Add an annotation of the following form to the pod specification:
metadata:
annotations:
nvidia.cdi.k8s.io/container.<container-name>: "<cdi-device>"
Replace <container-name> with the name of the container in the pod that the device is injected into, and replace <cdi-device> with the CDI device to request.
The NRI Plugin supports two kinds of CDI devices: non-management devices and management devices.
Requesting a Non-Management CDI Device#
A non-management CDI device injects a single GPU, identified by its GPU UUID, into a container. Pods can request a non-management CDI device from any namespace.
Retrieve the GPU UUID from the /var/run/cdi/k8s.device-plugin.nvidia.com-gpu.json file on the GPU node.
Request the device with an annotation of the form k8s.device-plugin.nvidia.com/gpu=<GPU-UUID>.
The following pod specification requests a specific GPU for the ubuntu container:
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
labels:
app: ubuntu
annotations:
nvidia.cdi.k8s.io/container.ubuntu: "k8s.device-plugin.nvidia.com/gpu=GPU-1d7f7c5b-b2f6-148d-ff9a-d8bc4941885c"
spec:
containers:
- image: ubuntu
name: ubuntu
command:
- "sleep"
- "604800"
imagePullPolicy: IfNotPresent
restartPolicy: Always
Requesting a Management CDI Device#
A management CDI device provides management-level access to all GPUs on the node, bypassing GPU allocation through the Device Plugin or DRA Driver for GPUs.
This is the access that a GPU Management Container requires.
Request a management device with the management.nvidia.com/gpu=all annotation value.
By default, only pods in the namespace where the GPU Operator is installed, which is the namespace where the NVIDIA Container Toolkit runs, are permitted to request management CDI devices.
To permit pods in other namespaces to request management CDI devices, add those namespaces to the NRI_MANAGEMENT_CDI_DEVICE_NAMESPACES environment variable on the NVIDIA Container Toolkit.
The value is a comma-separated list of namespaces.
Set the environment variable through the toolkit.env Helm value at installation time, or by modifying the cluster policy on an existing installation:
$ kubectl patch clusterpolicies.nvidia.com/cluster-policy --type='json' \
-p='[{"op": "replace", "path": "/spec/toolkit/env", "value": [{"name": "NRI_MANAGEMENT_CDI_DEVICE_NAMESPACES", "value": "test-namespace"}]}]'
The following pod specification, in test-namespace, requests a management CDI device for the ctr container.
For this pod to start, test-namespace must be included in the NRI_MANAGEMENT_CDI_DEVICE_NAMESPACES environment variable.
apiVersion: v1
kind: Pod
metadata:
name: cdi-nri-test
namespace: test-namespace
labels:
app: cdi-nri-test
annotations:
nvidia.cdi.k8s.io/container.ctr: "management.nvidia.com/gpu=all"
spec:
containers:
- name: ctr
image: ubuntu
imagePullPolicy: IfNotPresent
command:
- bash
- -c
- sleep infinity
Known Issues#
Pod specifications that set spec.hostUsers: false to enable Kubernetes user namespaces are not supported.
When a pod runs in its own user namespace, the NVIDIA Container Toolkit createContainer hook (nvidia-cdi-hook)
runs as the remapped user inside the container’s user namespace and cannot read the OCI bundle’s config.json to
determine the container root. As a result, container creation fails with an error such as:
Error: container create failed: read status from sync socket: No such process
As a workaround, omit the hostUsers field or set spec.hostUsers: true for any pods that request GPUs or that
are managed by the GPU Operator.
Refer to NVIDIA Container Toolkit issue #648 for more information.