Slurm GPU Workloads on Kubernetes with Slinky
Run large GPU jobs with Slurm on Kubernetes via Slinky: GPU NodeSets and GRES, DCGM job metrics, GB200 IMEX ComputeDomains, block topology, KEDA autoscaling.
💡 Quick Answer: NVIDIA runs Slurm on Kubernetes with Slinky at 1,000+ GPU nodes / 8,000+ GPUs, reporting NCCL all-reduce and all-gather results with no measurable difference from bare-metal Slurm. The recipe: GPU Operator for drivers and device plugin; a GPU NodeSet that requests
nvidia.com/gpuand declares matching GRES;gres.confwithAutoDetect=nvidia; DCGM Exporter HPC job mapping for per-job GPU metrics; on GB200 NVL72, one cluster-wide ComputeDomain plusSwitchType=switch/nvidia_imexand block topology; and KEDA to scale NodeSets on pending Slurm jobs.
The Problem
Getting Slurm running on Kubernetes is the easy part (see the install recipe). Running real multi-node GPU training on it raises harder questions:
- Double accounting of GPUs — Kubernetes allocates GPUs to the
slurmdpod; Slurm must then hand them to jobs as GRES - Observability — DCGM shows GPU utilisation per pod, but the pod is a whole Slurm node running many jobs
- NVLink domains — on GB200 NVL72 racks, multi-node NVLink needs IMEX, which Kubernetes manages through DRA
- Topology — Slurm must place a job’s ranks inside one NVLink block, not spread them across racks
- Elasticity — idle GPU nodes are expensive; scaling must not kill running jobs
The Solution
flowchart TD
GO[GPU Operator<br/>driver, device plugin, DCGM] --> W
DRA[NVIDIA DRA driver<br/>ComputeDomain / IMEX] --> W
TG[Topograph<br/>NVLink block discovery] --> CTL
subgraph Slurm on Kubernetes
CTL[slurmctld<br/>topology/block, switch/nvidia_imex]
W[GPU NodeSet<br/>slurmd pods, 1 per node]
CTL <--> W
end
W -->|job-mapping files| DCGM[DCGM Exporter<br/>hpcJobMapping]
DCGM --> P[Prometheus]
CTL -->|OpenMetrics| P
P --> K[KEDA ScaledObject] -->|scale| WStep 1: GPU NodeSet with GRES
The slurmd pod requests GPUs from Kubernetes; extraConfMap.Gres tells Slurm what it has. The two numbers must match.
# slurm-gpu-values.yaml
configFiles:
gres.conf: |
AutoDetect=nvidia
controller:
extraConfMap:
GresTypes: "gpu"
nodesets:
gpu-h100:
replicas: 4
partition:
enabled: true
configMap:
State: UP
MaxTime: UNLIMITED
slurmd:
resources:
requests:
cpu: "96"
memory: 900Gi
limits:
cpu: "96"
memory: 900Gi
nvidia.com/gpu: 8
extraConfMap:
Gres: ["gpu:H100:8"]
podSpec:
nodeSelector:
nvidia.com/gpu.product: NVIDIA-H100-80GB-HBM3
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedulehelm upgrade slurm oci://ghcr.io/slinkyproject/charts/slurm -n slurm \
--version "$SLINKY_VERSION" -f slurm-values.yaml -f slurm-gpu-values.yamlVerify from a login pod:
sinfo -o "%P %D %G"
# PARTITION NODES GRES
# gpu-h100 4 gpu:H100:8
srun -p gpu-h100 --gres=gpu:H100:8 nvidia-smi -LRequest whole nodes (all GPUs) per slurmd pod. The operator assumes one worker pod per Kubernetes node; if you want to share a node between Slurm and pod workloads at the single-node level, Slinky’s other project, slurm-bridge (Slurm as a Kubernetes scheduler), fits better.
Step 2: Multi-node NCCL test
#!/bin/bash
#SBATCH -p gpu-h100
#SBATCH -N 2
#SBATCH --ntasks-per-node=8
#SBATCH --gres=gpu:H100:8
#SBATCH --time=00:30:00
srun --mpi=pmix all_reduce_perf -b 8 -e 8G -f 2 -g 1all_reduce_perf must be in the slurmd image (the OpenHPC-based images from quay.io/slinky-on-openshift ship it as the nccl-tests module), or run it in a container with Pyxis. Inter-node bandwidth depends on your fabric — expose RDMA NICs to the worker pods as you would for any GPU pod (see GPUDirect RDMA with the GPU Operator).
Step 3: Per-job GPU metrics with DCGM
DCGM Exporter sees the slurmd pod, not the Slurm job. HPC job mapping fixes that: Slurm prolog/epilog scripts write a file per job listing its GPUs, and DCGM labels metrics with the job ID.
GPU Operator ClusterPolicy (or Helm) values:
dcgmExporter:
hpcJobMapping:
enabled: true
directory: /var/lib/dcgm-exporter/job-mappingMount the same host directory into the worker pods so prolog/epilog can write there:
nodesets:
gpu-h100:
slurmd:
volumeMounts:
- name: dcgm-job-mapping
mountPath: /var/lib/dcgm-exporter/job-mapping
podSpec:
volumes:
- name: dcgm-job-mapping
hostPath:
path: /var/lib/dcgm-exporter/job-mapping
type: DirectoryOrCreateYour prolog writes the job’s GPU indices to a file named after $SLURM_JOB_ID in that directory; the epilog removes it. Grafana can then chart DCGM_FI_DEV_GPU_UTIL by hpc_job.
Step 4: GB200 NVL72 — IMEX and block topology
Multi-node NVLink needs an IMEX domain across the nodes of a job. With the NVIDIA DRA driver, NVIDIA’s setup uses one cluster-wide ComputeDomain with numNodes: 0, so nodes join and leave IMEX dynamically as workers come and go:
apiVersion: resource.nvidia.com/v1beta1
kind: ComputeDomain
metadata:
name: slurm-imex
namespace: slurm
spec:
numNodes: 0
channel:
resourceClaimTemplate:
name: slurm-imex-channelAttach the channel claim to the GPU NodeSet’s pod spec (resourceClaims referencing slurm-imex-channel, and resources.claims on the slurmd container), then tell Slurm to manage IMEX channels per job and place jobs by NVLink block:
controller:
extraConfMap:
GresTypes: "gpu"
SwitchType: "switch/nvidia_imex"
TopologyPlugin: "topology/block"
TopologyParam: "BlockAsNodeRank" # Slurm 25.11+Block membership comes from the Kubernetes nodes: Topograph discovers NVLink domains from GPU Operator / DRA labels, and with operator v1.1.0+ (syncTopology: true on the NodeSet) workers register their topology dynamically, so no static topology.conf.
Step 5: Autoscale GPU NodeSets with KEDA
Enable Slurm metrics and a ServiceMonitor (Slurm 25.11+ exposes OpenMetrics):
controller:
metrics:
enabled: true
serviceMonitor:
enabled: true
labels:
release: prometheusScale the NodeSet on pending work:
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: scale-gpu-h100
namespace: slurm
spec:
scaleTargetRef:
apiVersion: slinky.slurm.net/v1beta1
kind: NodeSet
name: slurm-worker-gpu-h100
idleReplicaCount: 0
minReplicaCount: 1
maxReplicaCount: 16
triggers:
- type: prometheus
metricType: Value
metadata:
serverAddress: http://prometheus-kube-prometheus-prometheus.prometheus:9090
query: slurm_partition_max_pending_nodes{partition="gpu-h100"}
threshold: "1"slurm_partition_max_pending_nodes scales for one big multi-node job; slurm_partition_jobs_pending does not (one pending 16-node job counts as 1). On OpenShift, point serverAddress at Thanos Querier with a bearer-token TriggerAuthentication, as in the redhat-hpc/slinky-on-openshift deploy/keda example. Pair with Cluster Autoscaler or a MachineSet scaled from zero so new pods get new GPU nodes.
Scale-in is safe: the operator drains the Slurm node, waits for its jobs, and prefers removing pods whose jobs finish soonest.
KEDA is the path the upstream docs use. The NodeSet also exposes the scale subresource, so a plain HorizontalPodAutoscaler on Slurm metrics (through a Prometheus adapter) works too. That is how NVIDIA describes scaling “from a single pod to every available worker node”.
Step 6: Maintenance without killing jobs
# Kubernetes drain → Slurm DRAIN with the same reason
kubectl drain gpu-node-12 --ignore-daemonsets --delete-emptydir-data
# Rolling image update across hundreds of workers: same drain logic
helm upgrade slurm ... --set nodesets.gpu-h100.slurmd.image.tag=<new-tag>Keep workloadDisruptionProtection: true (PDBs on workers). Node health-check failures from Kubernetes are synced to Slurm, which drains the node rather than scheduling onto a bad GPU.
Common Issues
sinfo shows gres:(null) or jobs pend with Resources
Gres in extraConfMap doesn’t match what AutoDetect=nvidia finds, or GresTypes=gpu is missing on the controller. The GPU type string (H100, GB200) must match between the NodeSet and the job’s --gres.
Workers schedule but see no GPUs
The pod didn’t request nvidia.com/gpu, or the GPU Operator’s device plugin isn’t ready on that node. Check kubectl describe node <node> | grep nvidia.com/gpu.
KEDA never scales out for large jobs
You used slurm_partition_jobs_pending with a threshold > 1. Use slurm_partition_max_pending_nodes, and keep metricType: Value. Default cooldown is 5 minutes.
Multi-node NVLink jobs fail on GB200
No IMEX channel in the pod, or SwitchType isn’t switch/nvidia_imex. Check kubectl get computedomain -n slurm and that every worker’s pod has the channel claim allocated.
Best Practices
- One
slurmdpod per GPU node, requesting all GPUs — let Slurm, not Kubernetes, slice the node - Match GRES to pod limits exactly; mismatches show up as mysteriously pending jobs
- Turn on DCGM HPC job mapping before users ask “why is my job slow?”
- One cluster-wide ComputeDomain (
numNodes: 0) instead of per-job domains on NVL72 - Block topology so jobs stay inside an NVLink domain
- Scale on
max_pending_nodes, back it with node autoscaling, keep PDBs on - Slurm 25.11+ — needed for OpenMetrics autoscaling, cgroup v2 isolation inside
slurmdcontainers andBlockAsNodeRank
Key Takeaways
- Slurm-on-Kubernetes via Slinky matches bare-metal NCCL performance at 8,000+ GPU scale
- GPUs are allocated twice: Kubernetes →
slurmdpod, then Slurm GRES → job - DCGM job mapping gives per-Slurm-job GPU metrics
- ComputeDomain +
switch/nvidia_imex+topology/blockmake GB200 NVL72 work - KEDA + Slurm OpenMetrics scale GPU NodeSets with drain-safe scale-in
Book by Grzegorz Stencel & Luca Berton
Kubernetes Recipes
- Paperback · eBook
- Apress
- 750 pages
100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Book by Grzegorz Stencel & Luca Berton · Apress
Kubernetes RecipesGet the book