⚙️
Domain 3 · AI Operations · 22% of the exam

Containers for AI workloads

What a container is, how it differs from a VM, and how GPUs get into containers with the NVIDIA Container Toolkit and NGC.

Lesson 24 of 29~12 min read4 quiz questions5 key terms
Exam objectives this lesson covers
  • Describe AI cluster orchestration and job scheduling essentials.
  • Identify the key considerations for virtualizing accelerated infrastructure.
  • Describe the software components related to the life cycle of AI development and deployment.

Docker defines a container as a standard unit of software that packages code and all its dependencies so the application runs the same way anywhere. For AI this solves a real pain: a training job needs one exact combination of framework, CUDA libraries, cuDNN, NCCL and Python packages. Put it in a container and it runs identically on a laptop, a DGX and a cloud node.

Virtual machinesContainersHardwareHypervisorGuest OSGBsApp 1libsGuest OSGBsApp 2libsGuest OSGBsApp 3libsHardware + GPUHost OS kernel + container runtimeApp 1libs onlyApp 2libs onlyApp 3libs onlyApp 4libs onlyshare the host kernel · MBs · start in seconds
Fig 1. VMs each carry a full guest OS on a hypervisor. Containers share the host kernel and carry only the app and its libraries, so they are smaller and start faster.

01Image vs container

02Containers vs virtual machines

Virtual machineContainer
VirtualisesHardware (via a hypervisor)The operating system (shares the host kernel)
SizeTens of GB (full guest OS)Tens to hundreds of MB
Start timeMinutesSeconds
IsolationStrong (separate kernels)Process-level (namespaces, cgroups)
Typical AI useMulti-tenant isolation, vGPU desktopsPackaging and running training and inference

03How the pieces fit

Docker Engine launched as open source in 2013 and builds on Linux kernel features: namespaces (what a process can see) and cgroups (how much it can use). In 2015 Docker donated the image format and the runtime runc to the Open Container Initiative (OCI), so images work across engines. containerd, the core runtime underneath Docker, went to the CNCF, and it is also what Kubernetes usually runs.

04Getting the GPU into a container

A container does not see GPUs by default. The NVIDIA Container Toolkit configures the runtime to mount the GPU devices and driver libraries into the container at start time. The driver stays on the host; the container carries the CUDA libraries it needs.

# run nvidia-smi inside a CUDA container with all GPUs
docker run --rm --gpus all nvcr.io/nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi

# a PyTorch training container from NGC, two specific GPUs
docker run --rm --gpus '"device=0,1"' --ipc=host nvcr.io/nvidia/pytorch:24.05-py3 python train.py

On Kubernetes the same job is done by the GPU Operator (see GPU Operator). DGX OS ships with Docker Engine and the Container Toolkit already installed.

05Why AI teams standardise on containers

Shipping containers. Before them, every cargo was loaded differently at every port. A standard box fits every ship, crane and lorry. A software container is that standard box: the runtime does not care what is inside.

✦Key terms: flip the cards

What the exam looks for
  • Containers virtualise the OS and share the kernel; VMs virtualise hardware.
  • GPUs reach containers via the NVIDIA Container Toolkit; NGC supplies tested AI images.
  • Benefits: reproducibility, portability, fast scaling.
Common traps
  • The GPU driver runs on the host, not inside the container.
  • Containers give weaker isolation than VMs; strict multi-tenancy may need VMs or MIG.

?Quick quiz

1. What do containers share with the host?

Why: Containers share the host kernel.

2. Which component lets a Docker container use NVIDIA GPUs?

Why: The toolkit exposes GPUs and driver libraries to containers.

3. Where do you find NVIDIA-tested PyTorch containers?

Why: NGC hosts optimised, scanned AI containers.

4. A container image compared with a VM image is typically:

Why: No guest OS means MBs instead of GBs and seconds instead of minutes.

Score: 0 / 4

Original readingWhat Is a Container?, Docker ↗

This lesson explains the reading in plain language and adds the exam context around it. Read the original too: it is short, and seeing the vendor wording helps on exam day.

All lessons →
↑