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.
- 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.
01Image vs container
- A container image is the packaged, read-only template: code, runtime, system tools, libraries, settings.
- A container is a running instance of an image, executed by a container engine such as Docker Engine or containerd.
- Images live in registries; NVIDIA’s is the NGC catalog (
nvcr.io), with tested, security-scanned AI containers.
02Containers vs virtual machines
| Virtual machine | Container | |
|---|---|---|
| Virtualises | Hardware (via a hypervisor) | The operating system (shares the host kernel) |
| Size | Tens of GB (full guest OS) | Tens to hundreds of MB |
| Start time | Minutes | Seconds |
| Isolation | Strong (separate kernels) | Process-level (namespaces, cgroups) |
| Typical AI use | Multi-tenant isolation, vGPU desktops | Packaging 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
- Reproducibility: the same image gives the same results months later.
- Portability: laptop → DGX → cloud without reinstalling.
- Fast deployment and scaling: inference services start in seconds and scale out on Kubernetes.
- Isolation of dependencies: two teams can use different CUDA or framework versions on one node.
✦Key terms: flip the cards
- 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.
- 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
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.