Module 7 · AI infrastructureLesson 86 of 887 minAdvanced

GPU scheduling

GPUs are scarce and expensive, so deciding which job runs where, and when, has a big effect on cost and waiting times.

Try it

With "Spread out", submit a 4-GPU job and watch it wait while free GPUs are scattered. Switch to "Pack tightly" and try again.

A single high-end GPU can cost tens of thousands of dollars, and clusters have thousands of them. Idle GPUs waste money; queued jobs waste people's time. Scheduling decides who gets which GPUs.

Why GPU scheduling is hard

  • Jobs need several GPUs together: a training job may need 8 GPUs on one machine, or 512 across many, all starting at once (gang scheduling). Partial allocation is useless.
  • Topology matters: GPUs on the same machine talk over NVLink, far faster than the network. Jobs should get well-connected GPUs.
  • Fragmentation: scattered free GPUs can't satisfy a big job, even when the total is enough.
  • Mixed workloads: long training runs, short experiments, and latency-sensitive inference compete for the same hardware.

Common techniques

  • Bin packing: place jobs on the fullest machine that fits, leaving whole machines free.
  • Queues and quotas: each team gets a guaranteed share; unused share can be borrowed.
  • Priorities and preemption: urgent jobs can pause lower-priority ones, which must checkpoint so they can resume.
  • Backfilling: run small, short jobs in gaps while a big job waits for its full allocation, as long as they won't delay it.
  • GPU sharing: split one GPU between small workloads (time slicing, MIG partitions on NVIDIA GPUs) for inference and notebooks.

Tools

Slurm is the classic for training clusters. On Kubernetes, the NVIDIA device plugin exposes GPUs, and schedulers like Kueue, Volcano or Run:ai add queues, gang scheduling and quotas. Clouds add their own capacity reservations and spot GPUs.

Quick check

Six GPUs are free across three machines (two per machine), but a job needing four GPUs on one machine still waits. What is this called?