Kubernetes for AI Workloads: GPU Scheduling Basics for Developers

How Kubernetes schedules GPUs: device plugins, pod specs, node labels, MIG and time-slicing, and gang scheduling for distributed AI training jobs.

By Galactic News Editorial · Published 2026-11-17T02:18:31+00:00 · Updated 2026-11-17T02:18:31+00:00

Kubernetes for AI workloads GPU scheduling basics for developers

Kubernetes for AI Workloads: GPU Scheduling Basics for Developers

Kubernetes does not see GPUs out of the box. It knows CPU, memory and storage. Everything else arrives through a device plugin. Once that plugin is in place, a pod requests GPUs as an extended resource, the scheduler places it on a node with free GPUs, and the container runtime exposes the devices to the container. This guide explains how that chain works, how to request GPUs correctly, and how to share them when one pod per card wastes expensive hardware.

The short version: install the vendor driver and device plugin, request whole GPUs in the pod's resource limits, use node labels to pick the right card, and add gang scheduling when a training job needs many pods at once.

How Kubernetes sees a GPU

A GPU node needs three pieces before any pod can request a card. First, the vendor driver on the node. Second, a container runtime that passes the device through, usually the NVIDIA Container Toolkit configured for containerd. Third, a device plugin. The plugin is what makes the GPU appear as a schedulable resource.

The device plugin framework has been stable since Kubernetes 1.26. A vendor daemon on each node registers with the kubelet and advertises an extended resource, for NVIDIA that is nvidia.com/gpu, as a plain integer. A node with eight cards reports eight units. A pod that asks for one takes one. The scheduler treats that integer like any other countable resource. It only ever sees what the kubelet reports.

The NVIDIA GPU Operator bundles the driver, the toolkit, the device plugin, node feature discovery and monitoring into one install. On any cluster where you control the nodes, it is worth using rather than assembling the pieces by hand. It deploys the components as DaemonSets and reconciles them from one ClusterPolicy resource.

Kubernetes for AI workloads: requesting GPUs in a pod spec

GPUs follow stricter rules than CPU and memory. The Kubernetes documentation states that GPUs are only supposed to be specified in the limits section. You can specify GPU limits without specifying requests, because Kubernetes uses the limit as the request value by default. You can specify both, but the two values must be equal. You cannot specify GPU requests without limits.

A minimal example looks like this. The container requests one whole GPU in its limits. The scheduler places the pod only on a node with a free GPU. The pod gets the entire device, exclusively, for the life of the pod.

resources:
limits:
nvidia.com/gpu: 1

There are no fractions and no overcommit by default. A request for one GPU means one whole device. You cannot ask for half a GPU, and you cannot ask for a specific card, such as GPU 0 rather than GPU 3. The device plugin handles assignment. A GPU request also does not reserve CPU or memory. Set those separately, or your training job will run out of memory while the GPU sits idle.

Check the node first when a pod sits pending. Run kubectl describe node and look under Capacity and Allocatable for the plugin's resource name. If nvidia.com/gpu is missing, the plugin or driver is the problem, not the scheduler. The gap is almost always one layer down: nothing told the kubelet the GPUs exist.

Picking the right card: labels, affinity and taints

The scheduler knows the count of GPUs. It cannot tell an L4 from an H100. Model selection happens through node labels. NVIDIA's GPU Feature Discovery writes labels such as nvidia.com/gpu.product, nvidia.com/gpu.count and memory labels onto each node. You then use a nodeSelector or affinity rule to steer pods to the right hardware.

For mixed clusters, label nodes by GPU type and constrain placement with affinity. For example, a pod that needs a large-memory card for inference gets an affinity rule matching the H100 label. A pod that only needs a small card for testing gets the L4 label. Without labels, the scheduler may place a heavy job on a small card and leave the big cards idle.

Taint your GPU nodes. Without a taint, ordinary workloads such as logging agents and CI runners will fill GPU nodes while your training job sits pending. A taint keeps non-GPU pods off the expensive hardware. Add the matching toleration only to pods that actually need a GPU.

Sharing a GPU: MIG, time-slicing and MPS

One pod per GPU wastes hardware when workloads are small. A lightweight inference service does not need a whole card. Three sharing methods exist, and they differ in what they isolate.

MIG, or Multi-Instance GPU, partitions a card at the hardware level. On A100, H100 and newer cards, one device becomes up to seven isolated instances with dedicated memory and compute. Each instance appears as its own resource, such as nvidia.com/mig-1g.5gb. This is the safest sharing method, because instances are isolated from each other.

Time-slicing advertises one physical GPU as several logical ones through a device plugin ConfigMap. The driver context-switches between them. There is no memory or fault isolation between replicas. It suits development and testing, where a crash is cheap. It is a poor choice for production inference, where one workload can starve another.

MPS, the Multi-Process Service, caps memory and compute per client through the MPS daemon. It sits between the two: better isolation than time-slicing, weaker than MIG. Choose MIG for production, time-slicing for dev and test, and MPS when you need per-client caps without MIG hardware.

MethodWhat is isolatedMemory limit per workloadHardware
Whole GPU (default)Everything; one pod per deviceFull cardAny NVIDIA GPU
MIGCompute and memory, hardware-isolatedPer instanceA100, H100 and newer
Time-slicingNothing; no isolation between replicasNoneAny, including cards without MIG
MPSMemory and compute capped per clientPer client capAny supported GPU

Gang scheduling: when a job needs all its pods at once

The default scheduler places pods one at a time, independently. That breaks distributed training. A job needs eight pods, all running at once, communicating over NCCL. Six get scheduled. Two sit pending because the cluster is full. Nobody makes progress, and the six running pods burn GPU hours waiting.

Kueue is the Kubernetes-native answer. It sits in front of the scheduler, holds jobs until the full resource set is available, then admits them all at once. Volcano covers the same ground with a batch-oriented scheduler and more scheduling policies. Use one of them for any distributed training workload. Do not rely on the default scheduler for multi-pod jobs.

Quotas and the road ahead

Cap GPU use per namespace with a ResourceQuota. The quota's hard section includes the extended-resource key, such as requests.nvidia.com/gpu. Kubernetes then admits only workloads whose aggregate GPU requests fit within the namespace limit. This stops one team from taking every card in the cluster.

Dynamic Resource Allocation, or DRA, is the longer-term change. It replaces bare GPU counts with device claims, so a pod can describe the device it wants rather than just asking for a number. The core of DRA reached general availability in Kubernetes 1.34. Vendor support is still catching up. For most clusters today, the device plugin is still how GPUs are scheduled. Learn the plugin model first. DRA builds on the same concepts.

Bottom line

Install the driver and device plugin, request whole GPUs in limits, use labels to pick the right card, taint GPU nodes, and add Kueue for distributed training. Share cards with MIG in production and time-slicing in development. Check the node capacity before blaming the scheduler when a pod sits pending. The chain is simple once you see it: driver, plugin, kubelet, scheduler, pod.