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.
- 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.
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-smiOn 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.
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: 1nvidia-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.
# 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 -mutilization.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 -qprints 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.
| Link | Scope | Typical use in inference |
|---|---|---|
| NVLink / NVSwitch | GPUs in one node or rack-scale domain | Tensor parallelism; fast KV transfer |
| PCIe | GPU to CPU, NIC, storage | Loading weights, host offload, budget multi-GPU |
| InfiniBand / RoCE + RDMA | Between nodes | Pipeline parallelism, disaggregated KV transfer |
| Ordinary Ethernet (TCP) | Between services | Client 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.
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.