Kubernetes does not know what a GPU is: a device plugin tells the kubelet how many a node has, the scheduler treats them as a countable extended resource, and the NVIDIA Container Toolkit puts the device and its driver into the container when a pod gets one. A whole H100 is often far more than one model needs, so GPUs get shared: MIG cuts one into isolated slices with their own memory, and time-slicing lets several pods take turns on one without isolation. This lesson follows one inference pod from nvidia.com/gpu: 1 to its first token, and shows what goes wrong when the model does not fit its slice or a neighbour shares its GPU.
Difficulty: Advanced · Know this first: Lesson 230, Lesson 201, Lesson 94
This bar splits the time from pod creation to the first token, in seconds. It is a worked example, not a measurement. The image and the weights are most of it, which is why GPU autoscaling reacts in minutes, not seconds.
Choose the model's size, its precision, and its KV cache. The memory it needs decides the smallest MIG slice of an H100 80GB that can hold it, and how many replicas fit on one GPU.
memory ≈ (parameters × bytes per parameter + KV cache) × 1.1 · FP16 = 2 bytes, FP8 = 1, INT4 = 0.5 · H100 80GB slices: 1g.10gb ×7, 2g.20gb ×3, 3g.40gb ×2, 7g.80gb ×1
Fits a 3g.40gb slice: two replicas per GPU
Three questions. No score is saved anywhere — this is just you against the material.
GPUs on Kubernetes grow in four levels: first how a GPU becomes a schedulable resource, then running one model per GPU well, then sharing GPUs safely, and finally running a GPU fleet for cost and reliability.
At the basic level you know the chain. The GPU driver runs on the node. The device plugin tells the kubelet how many GPUs the node has. The scheduler places a pod that asks for nvidia.com/gpu only on a node with a free one. The container toolkit puts the device into the container.
Terms: extended resource, device plugin, GPU Operator, CUDA, VRAM, MIG, time-slicing, DCGM.
Where it breaks: a node whose driver is older than the CUDA version in the image; the container starts and fails at the first CUDA call.
Try it: Basic
Which component tells the kubelet how many GPUs a node has?
Now do it: On a GPU node, run kubectl describe node and find nvidia.com/gpu under Capacity and Allocatable.
At the intermediate level you run inference pods that start fast and land on the right hardware.
Troubleshooting: nvidia-smi inside the pod; the device plugin's logs; GPU Operator pods per node.
Try it: Intermediate
How much GPU memory does a 70B model need in FP16 for its weights alone?
Now do it: Run gpu_fit.py in Go deeper for a model you use, at FP16 and INT4.
At the advanced level you share GPUs and know the price of each method.
nvidia.com/gpu; "mixed" advertises each profile, such as nvidia.com/mig-1g.10gb. Reconfiguring slices drains the GPU.Observability: DCGM exporter per GPU and per MIG instance, with pod labels; alert on XID errors, ECC errors, and thermal throttling.
Try it: Advanced
A team wants to give 4 developers each a share of one GPU for notebooks. Isolation is not important; cost is. What fits?
Now do it: Write the time-slicing ConfigMap in Go deeper for replicas: 4 and find where the GPU Operator's ClusterPolicy refers to it.
At the master level you run GPUs as a scarce, expensive fleet. Idle GPU-hours are the biggest waste in most AI platforms, and capacity for the newest GPUs is not always there when you ask.
Try it: Master
Your GPU bill doubled while traffic grew 20 percent. Where do you look first?
Now do it: From DCGM data for one week, compute average SM active per GPU and list the GPUs below 20 percent.
The first question for any GPU workload is whether it fits. This script does the memory arithmetic for a few models and picks the smallest MIG slice of an H100 80GB that holds each one. Standard library only; python3 gpu_fit.py.
# gpu_fit.py - will the model fit, and on which slice of an H100 80GB?
BYTES = {"fp16": 2.0, "fp8": 1.0, "int4": 0.5}
# MIG profiles on an H100 80GB: (name, memory GB, how many fit on one GPU)
MIG = [("1g.10gb", 10, 7), ("2g.20gb", 20, 3), ("3g.40gb", 40, 2), ("4g.40gb", 40, 1), ("7g.80gb", 80, 1)]
def vram_gb(params_b, precision, kv_gb, overhead=0.10):
"""Weights + KV cache, plus about 10% for the CUDA context, activations and fragmentation."""
weights = params_b * BYTES[precision] # billions of params x bytes = GB
return round((weights + kv_gb) * (1 + overhead), 1)
def smallest_slice(need):
for name, mem, per_gpu in MIG:
if need <= mem:
return name, per_gpu
return None, 0
models = [("8B chat", 8, "fp16", 4), ("8B chat", 8, "int4", 4), ("70B chat", 70, "fp16", 10),
("70B chat", 70, "fp8", 10), ("embedder 0.3B", 0.3, "fp16", 0.5)]
print("model precision needs smallest MIG slice replicas per H100")
for name, p, prec, kv in models:
need = vram_gb(p, prec, kv)
sl, n = smallest_slice(need)
where = f"{sl:<20} {n}" if sl else "no single GPU: split across GPUs (tensor parallel)"
print(f"{name:<15} {prec:<9} {need:>5} GB {where}")
$ python3 gpu_fit.py model precision needs smallest MIG slice replicas per H100 8B chat fp16 22.0 GB 3g.40gb 2 8B chat int4 8.8 GB 1g.10gb 7 70B chat fp16 165.0 GB no single GPU: split across GPUs (tensor parallel) 70B chat fp8 88.0 GB no single GPU: split across GPUs (tensor parallel) embedder 0.3B fp16 1.2 GB 1g.10gb 7
Read it like this: an 8B model in FP16 needs a 3g.40gb slice (two per GPU), the same model in 4-bit fits seven to a GPU, and a 70B model does not fit one 80 GB GPU even in FP8 with its cache; it needs tensor parallelism across two or more. The 10 percent overhead is a rule of thumb; measure the real figure with nvidia-smi after loading.
apiVersion: v1
kind: Pod
metadata:
name: llm-0
namespace: inference
spec:
nodeSelector:
nvidia.com/gpu.product: NVIDIA-H100-80GB-HBM3
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
containers:
- name: server
image: registry.example.com/inference/vllm-server:0.11
args: ["--model", "/models/chat-8b", "--gpu-memory-utilization", "0.9"]
resources:
requests:
cpu: "4"
memory: 32Gi
limits:
nvidia.com/gpu: 1
memory: 32Gi
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 30
periodSeconds: 5
apiVersion: v1
kind: ConfigMap
metadata:
name: time-slicing-config
namespace: gpu-operator
data:
any: |-
version: v1
sharing:
timeSlicing:
resources:
- name: nvidia.com/gpu
replicas: 4
The GPU Operator's ClusterPolicy points the device plugin at this ConfigMap (devicePlugin.config.name); after that each GPU appears as four nvidia.com/gpu. For MIG, the MIG manager applies a profile chosen by a node label such as nvidia.com/mig.config=all-1g.10gb. Both manifests were parsed as YAML and follow the GPU Operator's documented format; apply them on a test GPU node first, because changing MIG layout or sharing drains the GPU.
kubectl exec -n inference llm-0 -- nvidia-smi kubectl get nodes -L nvidia.com/gpu.product,nvidia.com/mig.config kubectl -n gpu-operator get pods -o wide # in Prometheus, from the DCGM exporter: # DCGM_FI_DEV_GPU_UTIL DCGM_FI_PROF_SM_ACTIVE DCGM_FI_DEV_FB_USED DCGM_FI_DEV_XID_ERRORS
This is a composite of a failure pattern that keeps repeating; the numbers are illustrative. A platform team enabled time-slicing with eight replicas per GPU to fit more teams onto a small GPU pool.
GPU pools are split by isolation need: whole GPUs or MIG slices for production serving, time-slicing only for development and batch on its own nodes. Packing is measured by tokens per second and SM activity, not GPU utilization, which had been at 100 percent the whole time.
Design a GPU platform on Kubernetes for one customer-facing 8B chat model, three internal embedding models, and data scientists who run notebooks and occasional fine-tuning.
What latency does the chat model promise? How much memory does each model need, measured? How bursty is the notebook use? Which GPUs can you buy or reserve? What may one team's job do to another's?
Say H100 80GB nodes with 8 GPUs, chat at 30 requests a second needing 3 replicas at peak, embedding models of 1 to 2 GB each, and 12 data scientists.
A serving pool with MIG: chat replicas on 3g.40gb slices (two per GPU), embedders on 1g.10gb slices; a development pool with time-slicing at 4 replicas per GPU for notebooks; fine-tuning on whole GPUs with a queue. Taints and GFD labels per pool, pre-pulled images, weights on a shared read-only volume, DCGM metrics to Prometheus, KEDA on request queue depth for chat, and a warm floor of two replicas.
MIG gives isolation and predictable latency and fixes the slice sizes until you drain and reconfigure. Time-slicing is cheap and flexible and lets one user hurt others. Whole GPUs for fine-tuning waste capacity between jobs; a queue and a scheduler such as Kueue keep them busy.