> ## Content Index
> Fetch the complete content index at: https://skills.devopscube.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Kubernetes Container Device Interface (CDI) Explained
- URL: https://skills.devopscube.com/kubernetes-container-device-interface/
- Published: 2026-10-27T04:30:00.000Z
- Updated: 2026-10-30T16:34:09.000Z
- Author: Aswin Vijayan
- Tags: #tipcat-kubernetes, #tips, #template-no-img

[Kubernetes](https://devopscube.com/kubernetes-tutorials-beginners/?ref=skills.devopscube.com) can schedule a Pod onto a GPU node and allocate GPUs to workloads using Dynamic Resource Allocation (DRA) or a [device plugin](https://devopscube.com/kubernetes-ai-ml-features/?ref=skills.devopscube.com#kubernetes-device-plugins-stable).

But allocating a device is not enough. The container runtime still needs to know which device to expose inside the container and what runtime configuration is required to make that device usable.

Without the correct runtime configuration, the container may fail to start, or the application may not be able to access the allocated GPU.

The problem is that different GPU vendors, such as NVIDIA, AMD, and Intel, require different configurations to work inside containers.

Container runtimes need a standard way to understand these device-specific requirements without handling every hardware vendor differently.

This is where the **Container Device Interface (CDI)** comes in.

## What is Container Device Interface (CDI)

Container Device Interface (CDI) is a specification that provides a common way to expose hardware devices like GPUs, FPGAs, and NICs to containers.

It defines a specification file that describes the devices and the configuration needed to make them accessible inside containers.

Instead of requiring a container runtime to understand every device vendor's configuration, CDI uses a specification file (CDI spec) to describe the changes needed to make a device available inside a container.

A CDI-compatible container runtime like containerd and CRI-O reads this specification and applies the required configuration when creating the container.

The image below is a high-level overview of device details defined in the CDI spec file and how container runtimes make use of it to allocate devices to the container.

![image showing how container runtime gets device details from CDI spec file and use it to allocate devices](https://storage.ghost.io/c/25/1a/251ae7d7-1d78-4128-b9cb-68a35ee6596c/content/images/2026/10/image-134.png)

Let's understand how this works using our GPU example.

## How Container Device Interface Works

In Kubernetes, CDI works alongside DRA or Device Plugins. Whether its Device Plugins or DRA, CDIs role is the same.

The following shows how CDI plays its role in device allocation.

![image showing how CDI plays its role in device allocation](https://storage.ghost.io/c/25/1a/251ae7d7-1d78-4128-b9cb-68a35ee6596c/content/images/2026/10/image-135.png)

When a Pod requests a GPU, the Kubernetes scheduler selects a suitable GPU based on the Pod's requirements and schedules the Pod to a node where that GPU is available.

Once the Pod is scheduled, the kubelet on that node calls the Kubernetes DRA driver through gRPC to prepare the allocated GPU.

Based on the allocation information, the DRA driver identifies the GPU and writes the device details into the CDI specification. The DRA driver then returns the CDI device ID (for example, `nvidia.com/gpu=gpu0`) to the kubelet.

The kubelet passes the CDI device ID to the container runtime. The runtime uses the CDI device ID to locate the matching device entry from the CDI spec file and applies the required configuration to make the GPU accessible inside the container.

To understand how the container runtime uses both the CDI ID and the CDI spec file, let's first look at the CDI specification file

## CDI Specification File

💡

****Note:** Infrastructure engineers usually don't need to write CDI specification files manually, as vendor tools can generate them. However, understanding these files helps you to [troubleshoot](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/cdi-support.html?ref=skills.devopscube.com#troubleshooting-cdi-specification-generation-and-resolution) situations where a container runtime cannot find or expose a GPU because of missing or outdated CDI specifications.

A CDI specification file describes the devices available on a node and the configuration required to expose them inside containers.

CDI spec file contains information like device type (kind), device name, configuration file path, and it supports both JSON and YAML formats.

For example, the following CDI spec file shows an entry for an NVIDIA GPU.

```yaml
cdiVersion: "0.6.0"
kind: nvidia.com/gpu
devices:
  - name: gpu0
    containerEdits:
      deviceNodes:
        - path: /dev/nvidia0
        - path: /dev/nvidiactl
```

The CDI specification files are usually stored in two locations on a Kubernetes worker node:

- **`/etc/cdi/`** – Stores CDI specification files that are meant to remain on the node, even after a reboot.
- **`/var/run/cdi/`** – Stores temporary CDI specification files generated by device management software (DRA/Device Plugin). These files may be updated automatically and are usually cleared after a reboot.

Both directories are read by container runtimes. If the same device is defined in both, the definition in **`/var/run/cdi/`** takes priority by default.

As you can see, a CDI specification can define multiple devices under the same device type. But how does the container runtime identify the exact device details to expose inside a container?

This is where the CDI Device ID is used.

## How CDI Device ID is Used?

Each device defined through CDI has a unique identifier, commonly called a **CDI Device ID**, which will be used by the container runtime to find the device details. The format of a CDI Device ID is:

```bash
<vendor>/<device-type>=<device-name>
```

For example, if you are using an NVIDIA GPU, the CDI ID will look like the example below.

```bash
nvidia.com/gpu=gpu0
```

When a container runtime receives this ID, it looks up the matching device entry in the CDI specification and applies the required container changes.

The following image shows how the container runtime uses the CDI ID to find the device details.

![image showing how the container runtime uses the CDI ID to find the device details](https://storage.ghost.io/c/25/1a/251ae7d7-1d78-4128-b9cb-68a35ee6596c/content/images/2026/10/image-136.png)

In summary, Device Plugin or DRA exposes the GPU to Kubernetes and CDI tells the container runtime how to expose that allocated device inside the container.