NVIDIA/k8s-device-plugin

NVIDIA device plugin for Kubernetes

What it is

The NVIDIA device plugin for Kubernetes is a small program that runs on every GPU-equipped machine in a Kubernetes cluster. It makes NVIDIA GPUs usable as ordinary, schedulable resources — so you can request "one GPU" for a container the same way you'd request CPU or memory.

The problem it solves

Kubernetes doesn't natively know anything about GPUs. Without this plugin, you'd have to manually assign GPUs to containers, track which ones are free, and detect failures yourself. This plugin automates all of that:

  • Discovers how many GPUs each node has and reports that count to Kubernetes
  • Monitors GPU health and removes unhealthy GPUs from the pool
  • Allocates GPUs to containers that request them

How it works

It runs as a DaemonSet — a Kubernetes construct that ensures one copy of the plugin runs on every node in the cluster. When a pod requests an nvidia.com/gpu resource, the plugin (via Kubernetes' device-plugin API) picks a healthy GPU and injects it into the container using the NVIDIA Container Runtime.

Key capabilities

  • Request GPUs in pod specs — e.g. nvidia.com/gpu: 1 in a container's resource limits
  • Multi-Instance GPU (MIG) support — split a physical GPU into multiple isolated instances, with three strategies: none, single, mixed
  • GPU sharing — two mutually exclusive modes:
    • Time-slicing: multiple workloads take turns on the same GPU (no isolation; a crash affects everyone)
    • MPS (Multi-Process Service): a control daemon partitions GPU memory and compute, giving each workload explicit limits
  • Flexible device-passing strategies — choose how the GPU list is communicated to the runtime: environment variable (default), volume mounts, CDI annotations, or CDI CRI field
  • Configurable device identification — pass GPUs by UUID (default) or by index (as shown in nvidia-smi)
  • GPU Feature Discovery — since v0.15.0, the repo also includes tooling to automatically label nodes with GPU properties (e.g. driver version, memory, model)

Configuration options

All options can be set via command-line flags, environment variables, or a YAML config file (precedence: flags > env vars > config file). Key ones:

Option What it does Default
MIG_STRATEGY How to expose MIG devices none
FAIL_ON_INIT_ERROR Fail the plugin if initialization errors occur, vs. block silently true
NVIDIA_DRIVER_ROOT Root path of the NVIDIA driver installation /
PASS_DEVICE_SPECS Pass device file paths/permissions (needed for CPUManager interop) false
DEVICE_LIST_STRATEGY How to pass the GPU list to the runtime envvar
DEVICE_ID_STRATEGY Whether to identify GPUs by UUID or index uuid
CONFIG_FILE Path to a YAML config file ""

Prerequisites

  • NVIDIA drivers ~= 384.81 or newer
  • nvidia-docker >= 2.0 or nvidia-container-toolkit >= 1.7.0
  • nvidia-container-runtime configured as the default low-level runtime
  • Kubernetes >= 1.10

Deployment

Quick start (for testing): apply a static DaemonSet manifest:

kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v0.17.1/deployments/static/nvidia-device-plugin.yml

Production: deploy via Helm chart, which supports ConfigMap-based configuration, per-node overrides via node labels, and integration with GPU Feature Discovery.

Known limitations (from the README)

  • No comprehensive GPU health checking
  • No GPU cleanup features
  • Official support only for NVIDIA's own plugin, not forks
  • If you don't request GPUs in a pod spec, the plugin exposes all GPUs on the machine inside your container (a warning, not a bug)

Example usage

apiVersion: v1
kind: Pod
metadata:
  name: gpu-pod
spec:
  restartPolicy: Never
  containers:
    - name: cuda-container
      image: nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0
      resources:
        limits:
          nvidia.com/gpu: 1

This requests one GPU; the plugin handles the rest.

Related

  • Project
  • Project
  • Project
  • Project
  • Project