InsightsAI Infrastructure
Running GPU workloads on Kubernetes without idle GPUs
How to schedule, share, autoscale and measure GPUs on Kubernetes so that expensive accelerators spend their time working instead of waiting.
Published November 24, 20263 min read
A single cloud GPU node can cost more per month than the rest of a small cluster combined. Yet GPU utilization in most clusters is low: a model server holds a whole GPU while using a fraction of it, training nodes sit idle overnight, and new replicas take minutes to start because the image and the model weights have to be downloaded first.
Kubernetes is a good platform for GPU workloads, but its defaults assume CPUs. These are the parts that need deliberate design.
Scheduling: keep GPU nodes for GPU work
GPUs reach Kubernetes through a device plugin, which advertises them as an extended resource, nvidia.com/gpu. The NVIDIA GPU Operator installs the plugin along with the driver, the container toolkit and a metrics exporter, so GPU nodes need no hand-built setup.
GPU nodes should only run pods that need a GPU. Taint the GPU node pool, and give GPU workloads a matching toleration and a resource request:
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
nodeSelector:
workload-class: gpu
containers:
- name: model-server
resources:
limits:
nvidia.com/gpu: 1Without the taint, ordinary pods fill the GPU nodes and the autoscaler cannot remove them, even when no GPU work is running.
Sharing: not every workload needs a whole GPU
A whole GPU is the default unit, and for many inference workloads it is far too much. There are two ways to share one:
- Multi-Instance GPU (MIG) splits supported data-center GPUs, such as A100 and H100, into isolated instances, each with its own memory and compute. Each instance appears to Kubernetes as a separate resource. Use it when workloads need predictable performance and isolation.
- Time-slicing, configured in the device plugin, lets several pods take turns on one GPU. Memory is not isolated, so one pod can starve the others. It suits development, notebooks and small models.
Batching: get more work from each GPU
For model serving, the server software matters as much as the hardware. A server that handles one request at a time leaves most of the GPU unused. Inference servers such as vLLM (continuous batching) and NVIDIA Triton (dynamic batching) combine concurrent requests into batches. The same GPU then serves many times the throughput, at a small cost in latency per request.
Measure throughput per GPU before adding replicas. The cheapest GPU is often the one you no longer need.
Autoscaling: scale on the work, not on CPU
CPU usage says little about a GPU workload. Scale on signals that reflect demand:
- For inference: requests in flight, queue depth, or the batch queue time the inference server reports. KEDA can scale on any of these from Prometheus.
- For batch jobs and training: the length of the job queue.
Let the node pool follow. The cluster autoscaler or Karpenter can scale a GPU pool to zero when no GPU pods are pending, and bring nodes back when they are. For anything not needed around the clock, scaling to zero saves the most money.
Start-up time limits how far you can scale down
Scaling to zero only works if scaling back up is fast enough for users. GPU images are large, and models are often several gigabytes. Each new node pays for both downloads:
- Keep images lean. Use a slim CUDA runtime base rather than the full development image, and leave the model weights out of the image.
- Cache model weights near the nodes, on a shared volume or a node-local cache, instead of downloading them from object storage on every start.
- Pre-pull images onto new GPU nodes, using the node image or a DaemonSet, so the first pod does not wait for the download.
Measure utilization, per team
The GPU Operator includes the DCGM exporter. Its metrics, such as DCGM_FI_DEV_GPU_UTIL for compute and DCGM_FI_DEV_FB_USED for memory, show which workloads actually use their GPUs:
avg by (namespace) (avg_over_time(DCGM_FI_DEV_GPU_UTIL[7d]))Put this on the same dashboard as cost per namespace. A model server averaging 8% utilization on a dedicated GPU is a strong candidate for MIG, time-slicing or batching. A training pool idle every night is a candidate for scaling to zero.
The result
GPUs run only GPU work, are shared where a whole one is wasteful, scale with demand and disappear when idle. The cost of AI workloads then grows with their use rather than with the number of models someone once deployed.