How to Install Docker with NVIDIA support?

Docker Tips & Tricks Series

Merwansky
2 min readFeb 2, 2022

In this article, you will see how to install Docker with NVIDIA support on Ubuntu, which will allow you to access the GPU(s) from the running container.

First things first, you need to install Docker CE, if not done yet follow the official instructions for your supported Linux distribution.

Setting up Docker

Docker-CE on Ubuntu can be installed using Docker’s official convenience script:

$ curl https://get.docker.com | sh \
&& sudo systemctl --now enable docker

Setting up NVIDIA Container Toolkit

Setup the stable repository and the GPG key:

$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

Install the nvidia-docker2 package (and dependencies) after updating the package listing:

$ sudo apt-get update$ sudo apt-get install -y nvidia-docker2

--

--

Merwansky
Merwansky

Written by Merwansky

Memento Mori Live in the present, and take advantage of opportunities Stop postponing things til tomorrow #science #technology #computer #vision #book #software