Kubernetes Schedules a GPU Only After a Device Plugin Advertises It as an Extended Resource

In progress Kubernetes

The Kubernetes scheduler knows CPU and memory by itself, but not GPUs. A GPU becomes schedulable only when a device plugin running on the node registers it with the kubelet as an extended resource such as nvidia.com/gpu, and the container runtime can then hand the device to the container. A working driver on the host is therefore the first of three layers, and pods stay Pending until all three work.

Three Layers, Three Failures

Layer Job When it is missing
Host driver the kernel can talk to the card nvidia-smi fails on the node
Container runtime hook containerd mounts the device and libraries into the container the plugin finds no GPU; the container can't see it
Device plugin the node advertises nvidia.com/gpu: 1 to the API server pods Pending with Insufficient nvidia.com/gpu

The device plugin runs as a DaemonSet. It inspects the node through the container runtime, so it sees the GPU only if it runs under NVIDIA's runtime: as containerd's default, or through a RuntimeClass set on the plugin's pods. When containerd's default stays runc and no RuntimeClass is set, the plugin itself can't find the card, and no pod that requests one can be scheduled.

How Requests Work

A pod asks for GPUs in resources.limits, as a whole number: nvidia.com/gpu: 1. Unlike CPU, an extended resource isn't overcommitted or shared by default. A container gets the whole device, and a second pod waits until it is released. The scheduler counts allocated devices, not GPU load: a card held by an idle pod is unavailable to every other pod.

Sharing is opt-in, in the device plugin rather than in the scheduler: with time-slicing, the plugin advertises one card as several nvidia.com/gpu, so several pods can each get one. They take turns on the card but all see its whole memory, so this shares a GPU without isolating the pods from each other (see Time-Slicing Lets Pods Share a GPU but Not Isolate Its Memory).

References

Review cards

Flashcard The NVIDIA driver works on the node, yet a pod requesting `nvidia.com/gpu: 1` stays Pending. What is missing, and where do you check?

The scheduler only knows CPU and memory; a GPU exists for it once a device plugin advertises nvidia.com/gpu. Check that kubectl describe node lists it under Capacity and Allocatable.

Flashcard containerd's default runtime is still runc. Why do GPU pods stay Pending?

The device plugin inspects the node through the default runtime, so it can't see the GPU and never advertises nvidia.com/gpu to the scheduler.

Flashcard A node has one GPU, held by an idle pod. Can a second GPU pod be scheduled there?

No. Extended resources aren't shared or overcommitted by default: the scheduler counts the card as allocated, whatever its load, until the first pod releases it.

Flashcard Where is a GPU shared between pods when you need it, and at what cost?

In the device plugin: time-slicing advertises one card as several nvidia.com/gpu. The pods take turns on the card but share its whole memory, with no isolation between them.