Day 0: The Training Ground
Goal: Build a kind cluster with CPU and GPU nodes, provide simulated A100 GPUs with Mokka, and understand what is real about it and what is not · Duration: approx. 60 min · Prerequisite: a Linux VM with Docker
Briefing
- In this course, you run GPU infrastructure for AI teams: detect GPU nodes, schedule, share, allocate and monitor GPUs, and fix failures. You do not need a graphics card for that.
- Mokka (NVIDIA, project
k8s-test-infra) simulates, on ordinary CPU nodes, the interface through which all NVIDIA tools talk to the driver: the library NVML (libnvidia-ml.so). Whoever asks this library sees GPUs. - Everything above it is real: the NVIDIA Device Plugin, GPU Feature
Discovery, the DRA driver,
nvidia-smi, the scheduler, Kueue, the DCGM Exporter. These programs run unchanged, just as on a server with real cards. - What is simulated are the GPUs themselves: model, memory, metrics and errors. Mokka cannot compute. CUDA programs and real AI inference on the GPU do not run here. Where this matters in the course, it is stated explicitly.
nvidia-smi · Device Plugin · DRA driver · DCGM Exporter ← real software
│ asks
libnvidia-ml.so (NVML) ← Mokka simulates
│
no GPU, no driver, no kernel module ← CPU node
| Node | Role |
|---|---|
gpu-control-plane |
Control plane |
gpu-worker |
CPU node for normal workloads |
gpu-worker2 |
GPU node with 8 simulated A100s |
Drill 1: The Tools
Everything runs on a VM with Docker. In this course’s lab, that is an Ubuntu VM with 4 vCPUs and 8 GB RAM.
docker version --format "Docker {{.Server.Version}}"
docker info --format "cgroup {{.CgroupVersion}}"
nproc
free -h | head -2Expected:
Docker 29.10.0
cgroup 2
4
total used free shared buff/cache available
Mem: 7.8Gi 677Mi 3.1Gi 2.6Mi 4.3Gi 7.1Gi
kind, kubectl and Helm:
ARCH=$(dpkg --print-architecture)
curl -sLo /tmp/kind https://kind.sigs.k8s.io/dl/v0.33.0/kind-linux-$ARCH
sudo install /tmp/kind /usr/local/bin/kind
curl -sLo /tmp/kubectl https://dl.k8s.io/release/v1.37.2/bin/linux/$ARCH/kubectl
sudo install /tmp/kubectl /usr/local/bin/kubectl
curl -sL https://get.helm.sh/helm-v4.3.2-linux-$ARCH.tar.gz | tar xz -C /tmp
sudo install /tmp/linux-$ARCH/helm /usr/local/bin/helm
kind version
kubectl version --client | head -1
helm version --shortExpected:
kind v0.33.0 go1.26.7 linux/amd64
Client Version: v1.37.2
v4.3.2+g8346aaa
The kind version matters. Each kind version ships with matching node images. With the older kind v0.31.0, a cluster with Kubernetes v1.37 fails right at startup:
error: your configuration file uses an old API spec: "kubeadm.k8s.io/v1beta3"
(kind: "ClusterConfiguration"). Please use kubeadm v1.36 instead ...
kind v0.31 still writes the kubeadm configuration in the old format, and kubeadm v1.37 no longer reads it. kind v0.33 has v1.37.0 as its default image.
Save your progress? Sign up for free
Drill 2: The Cluster
Three nodes, one of which gets the label gpu=mokka. GPUs
will appear only there later.
mkdir -p ~/gpu/tag00 && cd ~/gpu/tag00
cat > kind.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: gpu
nodes:
- role: control-plane
image: kindest/node:v1.37.0
- role: worker
image: kindest/node:v1.37.0
- role: worker
image: kindest/node:v1.37.0
labels:
gpu: mokka
EOF
kind create cluster --config kind.yaml
kubectl wait --for=condition=Ready node --all --timeout=180s
kubectl get nodes -L gpuExpected (abridged):
Creating cluster "gpu" ...
✓ Ensuring node image (kindest/node:v1.37.0) 🖼️
✓ Preparing nodes 📦 📦 📦
...
✓ Joining worker nodes 🚜
Set kubectl context to "kind-gpu"
NAME STATUS ROLES AGE VERSION GPU
gpu-control-plane Ready control-plane 32s v1.37.0
gpu-worker Ready <none> 20s v1.37.0
gpu-worker2 Ready <none> 19s v1.37.0 mokka
Each kind node is a Docker container with its own containerd. Mokka needs containerd 2.x, because NRI is enabled there, an interface through which a plugin can hook into the starting of containers:
docker exec gpu-worker2 containerd --version | cut -c1-60Expected:
containerd github.com/containerd/containerd/v2 v2.3.4 db8809
Save your progress? Sign up for free
Drill 3: Install Mokka
Mokka comes as a Helm chart. Two settings: the GPU model (profile
a100) and the node it should run on.
cat > mokka-werte.yaml <<EOF
gpu:
profile: a100
nodeSelector:
gpu: mokka
EOF
helm install nvml-mock oci://ghcr.io/nvidia/k8s-test-infra/chart/nvml-mock \
--version 0.7.0 --namespace mokka --create-namespace -f mokka-werte.yaml \
--wait --timeout 180s
kubectl -n mokka get pods -o wide | cut -c1-88Expected (abridged):
Pulled: ghcr.io/nvidia/k8s-test-infra/chart/nvml-mock:0.7.0
NAME: nvml-mock
STATUS: deployed
NOTES:
Mock GPU environment deployed on all nodes!
Profile: a100
GPUs per node: 8
Available profiles: a100, h100, b200, gb200, gb300, l40s, t4, vrnvl72
Driver version: 580.65.06
Mock driver root: /var/lib/nvml-mock/driver
...
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED
nvml-mock-6lc8z 2/2 Running 0 24s 10.244.2.2 gpu-worker2 <none>
“deployed on all nodes” is a fixed text in the chart. The Pod runs
only on gpu-worker2; the nodeSelector takes
effect. One Pod per node with two containers: one creates the simulated
driver, the other is the NRI plugin.
Save your progress? Sign up for free
Drill 4: What Mokka Puts on the Node
docker exec gpu-worker2 ls /var/lib/nvml-mock/driver
docker exec gpu-worker2 sh -c 'find /var/lib/nvml-mock/driver -maxdepth 3 \
-name "nvidia-smi" -o -maxdepth 3 -name "libnvidia-ml.so*"'
docker exec gpu-worker2 ls /var/lib/nvml-mock/driver/devExpected:
config
dev
etc
proc
usr
/var/lib/nvml-mock/driver/usr/bin/nvidia-smi
/var/lib/nvml-mock/driver/usr/lib64/libnvidia-ml.so.580.65.06
/var/lib/nvml-mock/driver/usr/lib64/libnvidia-ml.so
/var/lib/nvml-mock/driver/usr/lib64/libnvidia-ml.so.1
nvidia-uvm
nvidia-uvm-tools
nvidia0
nvidia1
nvidia2
nvidia3
nvidia4
nvidia5
nvidia6
nvidia7
A complete driver directory, as found on a real GPU server:
nvidia-smi, the NVML library and eight device files. Only
it is not under /, but under
/var/lib/nvml-mock/driver. In this course, this path is
called the driver root. Every NVIDIA component gets it
as a setting later on.
Mokka has also reconfigured containerd:
docker exec gpu-worker2 ls /etc/containerd/conf.d/
docker exec gpu-worker2 grep -E 'enable_cdi|default_runtime_name' \
/etc/containerd/conf.d/50-mokka.tomlExpected:
50-mokka.toml
enable_cdi = true
default_runtime_name = "nvidia"
A runtime named nvidia as the default and CDI enabled:
exactly what the NVIDIA Container Toolkit sets up on a real server.
Save your progress? Sign up for free
Drill 5: nvidia-smi on the Node
nvidia-smi is the real program from NVIDIA. It loads
libnvidia-ml.so and queries it. Here it finds Mokka’s
library:
docker exec -e LD_LIBRARY_PATH=/var/lib/nvml-mock/driver/usr/lib64 gpu-worker2 \
/var/lib/nvml-mock/driver/usr/bin/nvidia-smi -LExpected:
GPU 0: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780000)
GPU 1: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780001)
GPU 2: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780002)
GPU 3: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780003)
GPU 4: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780004)
GPU 5: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780005)
GPU 6: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780006)
GPU 7: NVIDIA A100-SXM4-40GB (UUID: GPU-12345678-1234-1234-1234-123456780007)
Eight A100s with 40 GB each in a Docker container without a graphics card. The UUIDs give away the simulation: real UUIDs are random, these count up.
Save your progress? Sign up for free
Drill 6: What Is Real and What Is Not
Is there really no NVIDIA hardware on the node? Every PCI device
reports a vendor ID; NVIDIA’s is 0x10de:
docker exec gpu-worker2 sh -c 'cat /sys/bus/pci/devices/*/vendor | sort | uniq -c'
docker exec gpu-worker2 sh -c 'ls /dev/nvidia* 2>&1'Expected:
1 0x1234
3 0x1af4
2 0x1b36
5 0x8086
ls: cannot access '/dev/nvidia*': No such file or directory
No 0x10de, no devices under /dev. And the
files under the driver root?
docker exec gpu-worker2 ls -l /var/lib/nvml-mock/driver/dev/nvidia0 /dev/nullExpected:
crw-rw-rw- 1 root root 1, 3 Nov 22 10:48 /dev/null
crw-rw-rw- 1 root root 195, 0 Nov 22 10:50 /var/lib/nvml-mock/driver/dev/nvidia0
A device file with number 195, the real major number of the NVIDIA driver. Only there is no driver behind it in the kernel. Anyone who wanted to open the file and compute would not get far. For everything that only asks via NVML, it is enough.
Save your progress? Sign up for free
Drill 7: Kubernetes Cannot Use It Yet
kubectl get node gpu-worker2 -o jsonpath='{.status.allocatable}{"\n"}'Expected:
{"cpu":"4","ephemeral-storage":"82086711296","hugepages-1Gi":"0","hugepages-2Mi":"0",
"memory":"8131756Ki","pods":"110"}
CPU, memory, Pods, but no GPU. A Pod that requests a GPU:
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: erster-versuch
spec:
containers:
- name: smi
image: ubuntu:24.04
command: [sleep, infinity]
resources:
limits:
nvidia.com/gpu: 1
EOF
sleep 5
kubectl get pod erster-versuch
kubectl get events --field-selector involvedObject.name=erster-versuch \
-o jsonpath='{.items[0].message}{"\n"}'Expected:
pod/erster-versuch created
NAME READY STATUS RESTARTS AGE
erster-versuch 0/1 Pending 0 6s
0/3 nodes are available: 1 node(s) had untolerated taint(s), 2 Insufficient
nvidia.com/gpu. preemption: 0/3 nodes are available: 3 Preemption is not helpful for
scheduling.
The kubelet knows nothing about the eight GPUs. Someone has to report
them to it as the resource nvidia.com/gpu. That is the job
of the Device Plugin, on Day 2. On Day 1, you first take a closer look
at how a GPU gets into a container in the first place.
Save your progress? Sign up for free
Exercise: Speed Drills
- Show which node Mokka runs on. Target time: 30 s
- Show the model, memory and power limit of the first three GPUs as CSV. Target time: 2 min
- Show the installed chart version of Mokka. Target time: 30 s
Solution
kubectl -n mokka get pods -o wide
docker exec -e LD_LIBRARY_PATH=/var/lib/nvml-mock/driver/usr/lib64 gpu-worker2 \
/var/lib/nvml-mock/driver/usr/bin/nvidia-smi \
--query-gpu=index,name,memory.total,power.limit,driver_version --format=csv | head -4
helm list -n mokkaExpected (abridged):
index, name, memory.total [MiB], power.limit [W], driver_version
0, NVIDIA A100-SXM4-40GB, 40960 MiB, 400.00 W, 580.65.06
1, NVIDIA A100-SXM4-40GB, 40960 MiB, 400.00 W, 580.65.06
2, NVIDIA A100-SXM4-40GB, 40960 MiB, 400.00 W, 580.65.06
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
nvml-mock mokka 1 ... deployed nvml-mock-0.7.0 0.7.0
Save your progress? Sign up for free
Checkpoint
kubectl get nodes -L gpuExpected: three nodes Ready with
v1.37.0, only gpu-worker2 with mokka in the
GPU column.
kubectl -n mokka get podsExpected: one Pod nvml-mock-… with
2/2 Running.
docker exec -e LD_LIBRARY_PATH=/var/lib/nvml-mock/driver/usr/lib64 gpu-worker2 \
/var/lib/nvml-mock/driver/usr/bin/nvidia-smi -L | wc -lExpected: 8
Challenge
A colleague claims: “If nvidia-smi shows eight GPUs,
there are eight GPUs in the server.” Disprove this with three commands
that have nothing to do with NVML.
Hint: How does the kernel recognize a device?
Solution
The commands from Drill 6: PCI vendor IDs (no 0x10de),
no device files under /dev, and the device file under the
driver root with no driver behind it. In addition:
docker exec gpu-worker2 sh -c 'grep -i nvidia /proc/modules || echo "kein NVIDIA-Modul"'Expected:
kein NVIDIA-Modul
nvidia-smi shows what NVML reports. Whether that is
true, only the kernel knows.
Save your progress? Sign up for free
Clean-up
kubectl delete pod erster-versuch --wait=falseKeep the cluster and Mokka. All following days build on them.
Interview Note
- What is NVML? The NVIDIA Management Library, the
driver’s C interface for queries and management.
nvidia-smi, the Device Plugin and the DCGM Exporter all talk to the GPU via NVML. - Why does a Pod without a Device Plugin show
Insufficient nvidia.com/gpu? Because the kubelet does not detect GPUs by itself. Extended resources likenvidia.com/gpuare registered by a Device Plugin; otherwise they do not appear inallocatableon any node. - Why simulated GPUs? To test and practice platform software without tying up expensive cards: scheduling, quotas, operators, monitoring and failure patterns. Performance and CUDA behavior cannot be tested this way.
Enterprise Note
- On real servers, the driver usually lives in the operating system
(package or driver container of the GPU Operator). The driver root is
then
/or/run/nvidia/driver. Exactly this setting is the difference between lab and production. - Many platform teams first test upgrades of the GPU Operator, Device Plugin and Kueue in a cluster with simulated GPUs. The real nodes stay free for workloads.
- GPU nodes are expensive. Whoever ties them up for tests or training pays by the hour. A practice cluster like this one costs only CPU and memory.