Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
For a container to see a GPU, the container runtime itself must be the NVIDIA runtime, which hooks into container startup to mount the driver libraries and device files. You select that runtime either by making it the node default or, more explicitly, via a RuntimeClass that pods reference by name. Understanding RuntimeClass matters because mixed clusters often want NVIDIA runtime only for GPU pods, and because 'the GPU isn't injected' frequently traces back to the wrong runtime being used. This is the layer between the device plugin advertising a GPU and the container actually receiving it.
A RuntimeClass named nvidia points at the NVIDIA container runtime handler. Pods that set runtimeClassName: nvidia are started with that runtime, which injects the GPU; pods that don't, aren't.
# Define a RuntimeClass that maps to the NVIDIA runtime handler.
apiVersion: node.k8s.io/v1
kind: RuntimeClass
metadata:
name: nvidia
handler: nvidia # matches the containerd runtime handler name
---
# A pod that explicitly opts into the NVIDIA runtime.
apiVersion: v1
kind: Pod
metadata:
name: gpu-with-runtimeclass
spec:
runtimeClassName: nvidia
containers:
- name: app
image: nvcr.io/nvidia/cuda:12.5.0-base-ubuntu22.04
command: ["nvidia-smi"]
resources:
limits:
nvidia.com/gpu: 1