Pidoku

The Software Stack

Module 5 Lesson 5.a 40 min Difficulty 2/5

Prerequisites 4.a, 3.j


Before you start: words you need#

WordPlain meaning
DriverThe operating-system component that owns the GPU hardware. One version per machine.
CUDANVIDIA’s platform for running general computation on its GPUs: a language extension, a compiler (nvcc), and runtime libraries.
CUDA toolkit / runtimeThe compiler, headers and libcudart that an application is built against. Versioned separately from the driver (CUDA 13.x in 2026).
Kernel libraryA collection of hand-tuned GPU kernels for common jobs, such as matrix multiply (cuBLAS).
FrameworkA higher-level system that decides which kernels to run: PyTorch, vLLM, llama.cpp.
NVMLNVIDIA Management Library: reads GPU temperature, memory use, errors. nvidia-smi is built on it.
ContainerA packaged application with its own libraries, sharing the host’s operating-system kernel (3.j).

1. What is it?#

Between an inference server and the GPU’s transistors sit several layers. Knowing them is how you fix the most common GPU errors — “CUDA driver version is insufficient”, “no CUDA-capable device”, “no kernel image is available for execution on the device” — because each message comes from one specific layer.

flowchart TB
  APP["Your application<br/>inference service, script"]
  SRV["Engine or framework<br/>vLLM, SGLang, PyTorch, llama.cpp"]
  KDSL["Kernel languages<br/>Triton, CUTLASS / CuTe DSL"]
  LIB["Kernel libraries<br/>cuBLAS, cuDNN, FlashInfer, NCCL"]
  RT["CUDA runtime<br/>libcudart, nvcc"]
  DRV["NVIDIA driver<br/>kernel module + libcuda, libnvidia-ml"]
  HW[("GPU hardware")]
  APP --> SRV --> LIB --> RT --> DRV --> HW
  SRV --> KDSL --> RT
  NVML["NVML<br/>nvidia-smi, DCGM, go-nvml"] --> DRV
  class APP,SRV compute
  class LIB,RT,KDSL io
  class DRV,NVML neutral
  class HW memory

2. Why does it exist?#

No one writes every GPU operation by hand. Each layer packages work so the one above can reuse it: the driver hides the hardware, CUDA gives a programming model, libraries provide fast kernels for common maths, and frameworks pick and sequence kernels for a whole model. The layering is also what lets you upgrade the parts independently — if you respect one compatibility rule (section 5).


3. Simple analogy#

A restaurant: the driver is the building’s gas and electricity, the CUDA runtime is the standard kitchen equipment, kernel libraries are pre-made sauces from expert suppliers, the framework is the head chef deciding which dishes to cook in which order, and your application is the menu. If the gas is too old for the new oven, nothing cooks — which is exactly the driver/runtime rule below.


4. Tiny example#

Read GPU state from a program. Tools that watch or schedule GPUs (Kubernetes device plugins, DCGM, autoscalers) all start like this. This version shells out to nvidia-smi’s machine-readable output, so it needs no libraries:

Go
// gpus.go — list GPUs using nvidia-smi's CSV output.
package main

import (
	"encoding/csv"
	"fmt"
	"os/exec"
	"strings"
)

type GPU struct {
	Index, Name, Driver              string
	MemUsedMiB, MemTotalMiB, UtilPct string
	TempC, PowerW                    string
}

func List() ([]GPU, error) {
	out, err := exec.Command("nvidia-smi",
		"--query-gpu=index,name,driver_version,memory.used,memory.total,utilization.gpu,temperature.gpu,power.draw",
		"--format=csv,noheader,nounits").Output()
	if err != nil {
		return nil, fmt.Errorf("nvidia-smi not available: %w", err)
	}
	rows, err := csv.NewReader(strings.NewReader(string(out))).ReadAll()
	if err != nil {
		return nil, err
	}
	var gpus []GPU
	for _, r := range rows {
		for i := range r {
			r[i] = strings.TrimSpace(r[i])
		}
		gpus = append(gpus, GPU{r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7]})
	}
	return gpus, nil
}

func main() {
	gpus, err := List()
	if err != nil {
		fmt.Println(err)
		fmt.Println("(no NVIDIA GPU here — that is fine; read the code and move on)")
		return
	}
	for _, g := range gpus {
		fmt.Printf("GPU %s  %-24s driver %s  %s/%s MiB  util %s%%  %s C  %s W\n",
			g.Index, g.Name, g.Driver, g.MemUsedMiB, g.MemTotalMiB, g.UtilPct, g.TempC, g.PowerW)
	}
}

The same in Python is pynvml (or nvidia-ml-py); production tools use NVML directly through go-nvml or DCGM.


5. Technical explanation#

The layers, bottom up#

LayerWhat it isWhere it lives
DriverKernel module that owns the hardware, plus user-space libcuda and libnvidia-mlOn the host; one version per machine
CUDA toolkit / runtimelibcudart, the nvcc compiler, headers, PTX toolsWith the application (usually inside the container)
Kernel librariescuBLAS/cuBLASLt (matrix maths), cuDNN (neural-net layers), NCCL (multi-GPU communication, 9.f), FlashInfer and FlashAttention (attention, 13.l), TensorRT (optimising compiler, 15.c)With the application
Kernel languagesWays to write new kernels without raw CUDA C++: Triton (6.e), CUTLASS and its Python CuTe DSL, CUDA PythonWith the application
Framework / engineChooses and sequences kernels: PyTorch, vLLM, SGLang, TensorRT-LLM, llama.cppWith the application

The one compatibility rule#

The driver must be at least as new as the CUDA version the application needs. Drivers are backward compatible: a new driver runs old CUDA applications. An old driver cannot run a newer CUDA runtime, and fails with “CUDA driver version is insufficient for CUDA runtime version”.

Each CUDA major version names a minimum driver branch — for example CUDA 13.0 with the R580 branch — and within a major version, applications built with a newer minor release generally run on the older driver of that major version (“minor version compatibility”), with some features unavailable. Data-center GPUs can also use NVIDIA’s forward compatibility package to run a newer CUDA on an older driver.

The practical rule: keep host drivers current; let each application bring its own CUDA runtime and libraries. That is exactly how containers are used.

Compiled for which GPU?#

Kernels are compiled for specific compute capabilities (4.a): sm_90 for Hopper, sm_100 for B200, sm_103 for B300, sm_120 for RTX 50-series and RTX PRO Blackwell. A library built without your GPU’s target fails with “no kernel image is available” — or falls back to slower generic code. CUDA 13 also dropped compiler support for the oldest architectures (Maxwell, Pascal and Volta), so very old GPUs stay on CUDA 12.

This is why engine releases list supported GPUs, and why “works on H100” does not mean “fast on B200”: the fast Blackwell paths are separate kernels (4.f).

GPUs in containers#

A container shares the host’s kernel, so it must use the host’s driver — but carries its own CUDA libraries. The NVIDIA Container Toolkit handles the split: when a container starts, it injects the host’s driver libraries and GPU device files. The image supplies everything above the driver. In Kubernetes, the NVIDIA GPU Operator installs the driver, the toolkit and the device plugin on each node (21.c).

Shell
docker run --rm --gpus all nvidia/cuda:13.0.0-base-ubuntu24.04 nvidia-smi

If that prints the GPU table, the stack is healthy up to the driver.

Two APIs, two purposes#

  • CUDA — compute: allocate memory, copy data, launch kernels.
  • NVML — management: temperature, utilisation, memory use, processes, errors. nvidia-smi and DCGM are built on it; Kubernetes GPU components use it through go-nvml.

Beyond NVIDIA#

VendorCompute platformNotes
NVIDIACUDALargest library ecosystem; the default in AI
AMDROCm, HIP (a CUDA-like language)Supported by PyTorch, vLLM, SGLang; kernels via Triton, Composable Kernel, AITER (7.h)
GoogleXLA, JAX, PallasFor TPUs; vLLM has a TPU backend (7.i)
AWSNeuron SDK, NKIFor Trainium and Inferentia (7.j)
InteloneAPI, SYCLGPUs and Gaudi
AppleMetal, MLXUnified memory on M-series chips (15.e)

The concepts in this module — kernels, device memory, queues, synchronisation — carry to all of them under different names. Writing kernels in a portable layer such as Triton is one way engines support several vendors.


6. Under the hood#

What happens when an engine starts on a GPU:

1. The process loads libcuda (from the host driver, injected into the container).
2. The CUDA runtime creates a context on the device — a few hundred MB of GPU memory
   and a second or more of setup.
3. Libraries load their kernels; any kernel compiled only as PTX (portable intermediate code)
   is JIT-compiled for this GPU and cached on disk.
4. Frameworks may autotune or compile kernels (torch.compile, Triton, FlashInfer autotuning),
   which can take minutes on first start — another cold-start cost (20.g).

7. Performance implications#

  • Library versions are performance versions. A newer cuBLAS, FlashInfer or engine release often adds the fast kernels for the newest GPU. Upgrading the container can be worth more than any tuning.
  • JIT compilation and autotuning add start-up time; cache them on persistent disk or bake them into the image.
  • The driver rarely affects speed directly, but very old drivers can block a newer CUDA and therefore newer kernels.

8. Production implications#

  • Pin the full stack per release: driver branch on hosts; CUDA, libraries and engine in the image.
  • Upgrade drivers fleet-wide on a schedule, ahead of the CUDA versions your images need.
  • Use the official engine images for your hardware (CUDA vs ROCm builds), not hand-built ones.
  • Monitor through NVML/DCGM, not by parsing nvidia-smi text in production.

9. Common mistakes#

  1. Installing CUDA inside the container and also expecting to update the driver there. The driver always comes from the host.
  2. Upgrading the image’s CUDA past what the host driver supports.
  3. Assuming an image built for Hopper is fast on Blackwell without checking it includes sm_100/sm_103 kernels.
  4. Confusing nvidia-smi’s “CUDA Version” (the newest CUDA the driver supports) with the CUDA version your application uses.

10. Hands-on exercise#

  1. Run gpus.go (or its Python equivalent). On a machine without a GPU, confirm it fails cleanly.
  2. Extend it into a loop that prints one line per second, like a tiny nvidia-smi dmon.
  3. On a GPU machine, compare the “CUDA Version” printed by nvidia-smi with python -c "import torch; print(torch.version.cuda)". Explain both numbers.
  4. An image built for CUDA 13 fails on a host whose driver is from 2023. Which layer do you upgrade, and why not the other one?

11. Interview questions#

  1. State the driver/runtime compatibility rule.
  2. What does the NVIDIA Container Toolkit inject into a container, and what must the image bring?
  3. What is the difference between CUDA and NVML?
  4. What does “no kernel image is available for execution on the device” mean, and how do you fix it?
  5. Why can upgrading an engine image speed up inference on new GPUs without any config change?

12. Further reading#

Checked on 11 November 2026. CUDA 13.5 was released in early November 2026 (Vera Rubin support generally available).

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in