Education › Inference › Stage 1: GPU & systems foundation

GPU servers in practice

Drivers, containers and nvidia-smi on Linux; PCIe, NVLink and the network between nodes; storage for model weights.

Beginner ~30 min read Module 2 of 15

A GPU is only useful once the operating system, drivers, containers and scheduler can all see it, and once weights can reach it quickly. This lesson covers the Linux side of GPU servers: the driver and CUDA stack, running GPU containers on Docker and Kubernetes, the nvidia-smi commands you will use every day, how GPUs connect to each other inside a node and across nodes, and how model weights get from storage into VRAM.

After this module you can
  • Explain how the NVIDIA driver, CUDA runtime and container toolkit fit together
  • Run GPU workloads in Docker and request GPUs in Kubernetes
  • Use nvidia-smi to inspect memory, utilisation, processes and topology
  • Distinguish intra-node links (PCIe, NVLink) from inter-node networks (InfiniBand, RoCE)
  • Plan storage so model weights load fast and cold starts stay short

The software stack: driver, CUDA, containers

Three layers have to agree. The kernel driver on the host talks to the hardware and must be installed on the machine itself. The CUDA runtime and libraries (cuBLAS, cuDNN, NCCL) usually ship inside your container image with the inference engine. The driver must be new enough for the CUDA version inside the image; an old host driver is the most common reason a container reports no usable GPU.

The NVIDIA Container Toolkit connects the two: it lets Docker or containerd mount the GPU devices and the host's driver libraries into a container. After installing it, configure the runtime once and request GPUs per container.

Docker: configure the runtime once, then request GPUs per container
bash
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

# all GPUs, then only GPU 1
docker run --rm --gpus all ubuntu nvidia-smi
docker run --rm --gpus '"device=1"' ubuntu nvidia-smi

On Kubernetes, the NVIDIA device plugin advertises GPUs as the extended resource nvidia.com/gpu, and the GPU Operator can install the driver, toolkit, device plugin and the DCGM metrics exporter as one package. Pods request whole GPUs through resource limits; GPUs are not shared between pods unless you configure time-slicing or MIG partitions.

A pod that gets one GPU
yaml
apiVersion: v1
kind: Pod
metadata:
  name: gpu-check
spec:
  restartPolicy: Never
  containers:
    - name: cuda
      image: nvidia/cuda:12.4.1-base-ubuntu22.04
      command: ["nvidia-smi"]
      resources:
        limits:
          nvidia.com/gpu: 1

nvidia-smi: your first diagnostic tool

nvidia-smi ships with the driver. Its default view shows each GPU's model, driver and CUDA version, temperature, power, memory used out of total, utilisation, and the processes holding memory. Learn a few more forms and you can answer most "is the GPU the problem?" questions in seconds.

Everyday nvidia-smi
bash
# one CSV line per GPU every second
nvidia-smi --query-gpu=index,name,utilization.gpu,memory.used,memory.total,power.draw \
  --format=csv -l 1

# rolling stats: power, utilisation, clocks, memory
nvidia-smi dmon -s pucm

# how the GPUs connect to each other and to CPUs
nvidia-smi topo -m
Watch out

utilization.gpu only means a kernel was running during the sample window, not that the GPU was busy doing useful maths. A memory-bound decode loop can show 100% while using a fraction of the compute. Use it to spot idle GPUs, not to judge efficiency; the profiling lesson covers better signals.

  • Memory used near total with many requests queued usually means the KV cache is full.
  • A process you do not recognise holding VRAM is often a crashed or orphaned worker; free it before blaming the engine.
  • nvidia-smi -q prints everything, including ECC errors and throttling reasons, which explain sudden slowdowns.

Networking: inside the node and between nodes

When a model spans several GPUs, they exchange data constantly, so the links between them shape performance. Inside a node, GPUs connect over PCIe through the CPU or a PCIe switch, or directly over NVLink, NVIDIA's high-bandwidth GPU-to-GPU link, often through NVSwitch so every GPU reaches every other at full speed. nvidia-smi topo -m prints the matrix: NV# means NVLink, while PIX, PXB, PHB and SYS are PCIe paths of increasing distance.

Between nodes, traffic leaves through network cards. Inference clusters use InfiniBand or RoCE (RDMA over Converged Ethernet), both supporting RDMA, which lets a network card read and write remote memory without involving the remote CPU. With GPUDirect RDMA, the network card moves data straight to and from GPU memory. These links are an order of magnitude or more slower than NVLink, which is why tensor parallelism usually stays inside one node.

LinkScopeTypical use in inference
NVLink / NVSwitchGPUs in one node or rack-scale domainTensor parallelism; fast KV transfer
PCIeGPU to CPU, NIC, storageLoading weights, host offload, budget multi-GPU
InfiniBand / RoCE + RDMABetween nodesPipeline parallelism, disaggregated KV transfer
Ordinary Ethernet (TCP)Between servicesClient traffic, control plane

Storage: getting weights into VRAM

Before serving anything, a worker must read tens or hundreds of gigabytes of weights from storage into VRAM. That load time is the core of an inference cold start, and it decides how fast you can scale out.

  • Weights usually come as safetensors files, which can be memory-mapped and loaded quickly and safely.
  • Downloading from a model hub or object storage on every start is slow and fragile. Cache weights on local NVMe or a shared high-throughput file system, or bake them into a node image.
  • On Kubernetes, a pre-populated persistent volume or a node-local cache shared across pods avoids re-downloading per replica.
  • Measure the load path end to end: storage read throughput, PCIe transfer and any compilation or graph capture the engine does after loading.
Tip

Persistence mode (sudo nvidia-smi -pm 1) keeps the driver initialised when no process is using the GPU, avoiding a few seconds of driver start-up on every new process.

Hands-on practice

Get a GPU working end to end

  1. Rent a single-GPU cloud instance (or use a local NVIDIA GPU) running a recent Linux image with the NVIDIA driver installed.
  2. Run nvidia-smi and note the driver version, the highest CUDA version it supports, and total memory.
  3. Install the NVIDIA Container Toolkit, configure Docker with nvidia-ctk, and run docker run --rm --gpus all ubuntu nvidia-smi.
  4. Start the --query-gpu ... -l 1 command from this lesson in one terminal and run any GPU workload in another; watch memory and utilisation move.
  5. Run nvidia-smi topo -m and identify how the GPUs and network cards connect (on a multi-GPU instance, look for NV# entries).
  6. Time how long it takes to copy a 10 GB file from object storage versus from local NVMe on the instance, and note the difference as your cold-start budget.
  7. Shut the instance down when finished.
Cheat sheet

GPU servers in practice — at a glance

Main things to focus on

  • Host driver must support the CUDA version inside your image.
  • The container toolkit mounts GPUs into containers; Kubernetes exposes them as nvidia.com/gpu.
  • nvidia-smi utilisation means busy at all, not efficiently busy.
  • NVLink inside a node, InfiniBand or RoCE with RDMA between nodes.
  • Weight loading dominates cold starts: cache weights close to the GPU.
  • Check topology before placing a multi-GPU model.

nvidia-smi

nvidia-smiOverview: memory, utilisation, power, processes
nvidia-smi --query-gpu=... --format=csv -l 1Scriptable metrics every second
nvidia-smi dmon -s pucmRolling power, utilisation, clocks, memory
nvidia-smi topo -mGPU, NIC and CPU interconnect matrix
nvidia-smi -q -d PERFORMANCEThrottle reasons and clocks
sudo nvidia-smi -pm 1Enable persistence mode

Containers

sudo nvidia-ctk runtime configure --runtime=dockerWire the toolkit into Docker
docker run --gpus all IMAGEAll GPUs in a container
docker run --gpus '"device=0,1"' IMAGESpecific GPUs
CUDA_VISIBLE_DEVICES=0Limit which GPUs a process sees

Kubernetes

resources.limits: {nvidia.com/gpu: 1}Request one whole GPU
NVIDIA GPU OperatorDriver, toolkit, device plugin, DCGM exporter in one
kubectl describe node NODE | grep nvidia.com/gpuGPU capacity and allocation per node

topo -m legend

NV#Connected by # NVLinks
PIX / PXBSame PCIe switch / multiple PCIe switches
PHB / SYSThrough the CPU host bridge / across CPU sockets

Common pitfalls

  • A host driver too old for the image's CUDA version, so the container sees no GPU.
  • Reading 100% nvidia-smi utilisation as proof the GPU is used efficiently.
  • Downloading weights from the internet on every pod start.
  • Splitting a model across GPUs that only connect through the CPU (SYS) without measuring the cost.
  • Orphaned processes holding VRAM after a crash.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →