Contents
Running Jobs
Drivers, schedulers and the plumbing that gets work onto GPUs
A cluster is only useful if people can get work onto it reliably and fairly. This chapter covers the software stack from kernel driver to framework, the batch scheduler most HPC and AI clusters run on, the communication library that makes multi-GPU training possible, and the habits (checkpoints, fair share) that keep a shared machine healthy.
2.1The CUDA software stack
From the bottom up:
- Kernel module (
nvidia.koand friends). It owns the hardware, memory management (including Unified Memory / UVM), interrupts and error reporting. NVIDIA publishes an open-source version, open-gpu-kernel-modules, the default for Turing and newer GPUs. The Xid messages you read indmesgcome from here. - User-mode driver (
libcuda.so): the CUDA driver API, shipped with the driver. - CUDA runtime and toolkit (
libcudart,nvcc): what applications compile against. - Libraries: cuBLAS, cuDNN, NCCL, CUTLASS.
- Frameworks: PyTorch, JAX, plus higher-level tooling.
Compatibility rule: a newer driver runs older CUDA runtimes, but not the reverse. nvidia-smi prints the driver version and the maximum CUDA version it supports. Containers bundle their own runtime but must use the host's driver, injected by the NVIDIA Container Toolkit. See Containers & GPUs.
2.2Slurm
Slurm turns a pile of servers into a shared machine. Key concepts:
- Partitions: named groups of nodes with limits (
sinfolists them). - Jobs are submitted with
sbatch script.sh.#SBATCHlines in the script request resources:--nodes,--gpus-per-node,--time,--partition. - Allocation: the scheduler picks nodes (backfill, priority, Fair-share scheduling) and runs the script on the first one.
srunlaunches tasks across the rest. - Node states:
idle,alloc,drain(finish current work, take no new work) anddown.
Daily operator commands
squeue --me # what's running / pending and why sacct # history with exit codes scontrol show job <id> # everything about a job scontrol update NodeName=node-3 State=DRAIN Reason="gpu5 fan" sinfo -R # why nodes are drained scontrol requeue <id> # restart a job (from its checkpoint)
Draining with a clear reason is the polite way to say "this hardware is suspect" without killing anyone's job.
$ sbatch train.sh sbatch: error: Batch job submission failed: Requested node configuration is not available
2.3NCCL
NCCL ("nickel") implements the collectives distributed training runs on: all-reduce, all-gather, reduce-scatter, broadcast and send/recv. It discovers the topology (NVLink, NVSwitch, PCIe, NICs) and builds rings and trees to use it. See All-reduce (ring & tree).
Environment variables worth knowing
NCCL_DEBUG=INFOprints the chosen transport and channels. Read it.NCCL_IB_DISABLE=1forces TCP sockets instead of InfiniBand. It's useful on laptops and a disaster in production.NCCL_SOCKET_IFNAME/NCCL_IB_HCAselect interfaces.
Diagnosing
all_reduce_perffrom nccl-tests measures achievable bus bandwidth. Run it on idle nodes to catch bad links before users do.- Hung collectives end with a PyTorch watchdog timeout. The cause is usually one bad rank: a dead link, a lost GPU or a straggler that stopped responding.
2.4Checkpointing & fault tolerance
At thousands of GPUs, something fails every few hours. Checkpointing bounds the damage: on failure, you restart from the last saved state and lose at most one checkpoint interval.
Choosing the interval: too frequent wastes I/O time, too rare wastes compute on failure. A classic approximation (Young/Daly) is interval ≈ √(2 × checkpoint_cost × MTBF).
Making it cheap
- Shard checkpoints: each rank writes its own slice in parallel.
- Async checkpointing: copy to host memory, then write in the background.
- Keep a few recent checkpoints. Corrupt or partial saves happen.
Ops integration: scontrol requeue or a job-level retry loop, plus a warm spare pool, turns "a GPU died" into a 5-minute blip. That's the loop you practice in Fallen Off the Bus and The Slow Lane.
2.5Kubernetes & the GPU Operator
Kubernetes doesn't know about GPUs by default. The NVIDIA device plugin advertises nvidia.com/gpu as a schedulable resource. The GPU Operator installs and manages the whole stack as containers: driver, container toolkit, device plugin, DCGM exporter and MIG manager.
Differences from Slurm that matter for training
- Kubernetes schedules pods one at a time. Distributed training needs gang scheduling (all-or-nothing), provided by add-ons such as Kueue or Volcano.
- Topology awareness (same rack, same NVLink domain) needs extra configuration.
- It excels at mixed fleets: inference services, notebooks and CI next to batch jobs, often on MIG slices.
Many organizations run both: Slurm for large training, Kubernetes for everything else, sometimes on the same hardware.
Two Nodes, One Job
Your first multi-node training job won't even submit. Fix the batch script.