Guide

Use the GPU inside Docker with the NVIDIA Container Toolkit

Last updated: 1 December 2026

Most GPU software ships as containers. To let Docker use the card you need the NVIDIA driver on the host and the NVIDIA Container Toolkit.

Instant VPS from $7.99 a month

See Instant VPS plansHow ordering works

Add the toolkit

With the driver installed and Docker running, add NVIDIA's repository and install the toolkit:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit

Connect it to Docker and test

Configure the Docker runtime, restart Docker and run a test container that prints the GPU table:

sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
docker run --rm --gpus all ubuntu nvidia-smi

Use it in your own containers

Keep it safe

Ports published by containers bypass ufw rules. Bind them to 127.0.0.1 unless they must be public, and reach them with an SSH tunnel.

Need a GPU server?

See our GPU servers: NVIDIA T4 to H200, built to order, no ID documents, pay with Monero or Bitcoin. Use them within our acceptable use policy.

Questions and answers

Do I install CUDA on the host?
No. The container brings CUDA; the host needs the driver and the toolkit.

Can two containers share one GPU?
Yes, if memory allows; they compete for the same card.

What if the test fails?
Check that nvidia-smi works on the host first, then re-run the runtime configuration and restart Docker.

Does it work with Docker Compose?
Yes. Reserve the GPU device in the service definition.

Related guides

Ready to try it? Instant VPS from $7.99 a month

See Instant VPS plansHow ordering works