Navigation
🏭 Platform & Infrastructure· 12 min read

Cluster Managers

Slurm for training, Kubernetes for serving β€” architecture, GPU integration, job submission, and when to use each.

cluster-managerslurmkubernetesgpu-pluginorchestration

GPU clusters need a manager that allocates hardware to workloads, handles failures, and enforces priorities. Two systems dominate: Slurm for training and Kubernetes for serving. Most organizations run both.


1. Slurm: The Training Standard

Slurm (Simple Linux Utility for Resource Management) is a job scheduler designed for HPC β€” submit a script, request resources, wait in queue, run.

Why Training Uses Slurm

Distributed training has a unique requirement: all GPUs must be allocated simultaneously (gang scheduling). If you request 64 GPUs and only 60 are free, the job waits rather than starting with a partial allocation. Slurm handles this natively.

Job Submission

#!/bin/bash
#SBATCH --job-name=llama-70b-pretrain
#SBATCH --partition=gpu-a100
#SBATCH --nodes=8
#SBATCH --ntasks-per-node=8
#SBATCH --gpus-per-node=8
#SBATCH --cpus-per-task=12
#SBATCH --mem=0                    # all memory on node
#SBATCH --time=72:00:00
#SBATCH --exclusive                # no sharing

# Environment
module load cuda/12.4 nccl/2.21
export MASTER_ADDR=$(scontrol show hostname $SLURM_NODELIST | head -1)
export MASTER_PORT=29500

# Launch distributed training
srun torchrun \
    --nproc_per_node=8 \
    --nnodes=$SLURM_NNODES \
    --node_rank=$SLURM_NODEID \
    --master_addr=$MASTER_ADDR \
    --master_port=$MASTER_PORT \
    train.py --config configs/llama-70b.yaml

Key Slurm Concepts

ConceptWhat it doesExample
PartitionNamed group of nodes with shared propertiesgpu-a100, gpu-h100, cpu-only
QOS (Quality of Service)Priority level, time limits, resource limitshigh-priority, normal, preemptible
Fair-sharePrevents one team from monopolizing the clusterTeam A used 60% this week β†’ lower priority
Job arraysSubmit many similar jobs efficientlyHyperparameter sweeps
DependenciesJob B starts only after Job A completesPipeline: preprocess β†’ train β†’ evaluate

Slurm + Containers

Slurm doesn’t natively run containers. Use Pyxis + Enroot (NVIDIA) for container support:

#SBATCH --container-image=nvcr.io/nvidia/pytorch:24.10-py3
#SBATCH --container-mounts=/data:/data,/checkpoints:/checkpoints

srun python train.py  # runs inside the container

2. Kubernetes: The Serving Standard

Kubernetes orchestrates containerized workloads with auto-scaling, health checks, and rolling deployments β€” essential for serving.

GPU Support Stack

NVIDIA GPU Operator (installs everything automatically):
  β”œβ”€β”€ GPU Driver (kernel module)
  β”œβ”€β”€ CUDA Toolkit (container runtime)
  β”œβ”€β”€ NVIDIA Container Toolkit (GPU passthrough to containers)
  β”œβ”€β”€ GPU Device Plugin (exposes GPUs to K8s scheduler)
  β”œβ”€β”€ GPU Feature Discovery (labels nodes: gpu-model, memory, MIG)
  └── DCGM Exporter (GPU metrics for monitoring)

Deploying a GPU Workload

apiVersion: apps/v1
kind: Deployment
metadata:
  name: vllm-llama-70b
spec:
  replicas: 4
  selector:
    matchLabels:
      app: vllm
  template:
    metadata:
      labels:
        app: vllm
    spec:
      containers:
      - name: vllm
        image: vllm/vllm-openai:latest
        args: ["--model", "meta-llama/Llama-3.1-70B", "--tensor-parallel-size", "4"]
        resources:
          limits:
            nvidia.com/gpu: 4     # request 4 GPUs
            memory: "200Gi"
          requests:
            nvidia.com/gpu: 4
            memory: "200Gi"
        ports:
        - containerPort: 8000
      nodeSelector:
        nvidia.com/gpu.product: "NVIDIA-H100-SXM"  # specific GPU type
      tolerations:
      - key: "nvidia.com/gpu"
        operator: "Exists"
        effect: "NoSchedule"

Kubernetes Advantages for Serving

FeatureHow it helps serving
Horizontal Pod AutoscalerScale replicas based on queue depth or GPU utilization
Liveness/Readiness probesRestart crashed pods, drain unhealthy ones
Rolling updatesDeploy new model version with zero downtime
Service meshTraffic splitting for canary deployments
Namespaces + RBACIsolate teams, control who deploys what

3. Hybrid: Running Both

WorkloadWhere it runsWhy
Pre-training (weeks-long)SlurmGang scheduling, simplicity, --exclusive nodes
Fine-tuning (hours-days)Slurm or K8sEither works; K8s if you want auto-retry
RLHF (mixed train+infer)KubernetesNeed inference serving alongside training
Inference servingKubernetesAuto-scaling, health checks, rolling updates
Batch evaluationSlurmJob arrays, simple queue management
Data preprocessingEitherSlurm for HPC-style, K8s for cloud-native

The Typical Setup

On-prem cluster (DGX SuperPOD):
  └── Slurm manages all nodes
      β”œβ”€β”€ gpu-train partition (256 H100s for pre-training)
      β”œβ”€β”€ gpu-finetune partition (64 H100s for fine-tuning)
      └── gpu-eval partition (16 H100s for evaluation)

Cloud (AWS/GCP):
  └── Kubernetes manages all pods
      β”œβ”€β”€ vllm-serving namespace (auto-scaled inference)
      β”œβ”€β”€ batch-inference namespace (offline processing)
      └── dev namespace (experiments, notebooks)

For how GPUs are scheduled within these managers, see GPU Scheduling.


Self-Check

  • Write a Slurm job script for 8-node distributed training with containers
  • Deploy a GPU inference workload on Kubernetes with node selection
  • Explain gang scheduling and why Slurm is preferred for training
  • Design a hybrid Slurm + K8s setup for a team doing both training and serving
  • List the NVIDIA GPU Operator components and what each does

References