Table of Contents
Recently I tried to reinstall Ubuntu on my dev/ml rig, and at the very end, GRUB wasn't able to install correctly. I was too lazy to investigate the root cause and decided to try Pop!_OS instead. It worked well, however, I had some problems with installing nvidia-container toolkit. Here is a short post on how to make it right, in case I forget the procedure a few years from now.
Docker installation
Nothing fancy, just following the official instructions:
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo docker run hello-world
Now let's add our user to docker group so that we don't have to always use sudo to launch containers:
sudo groupadd docker
sudo usermod -aG docker $USER
Quick test to make sure it works:
docker run hello-world
Nvidia container toolkit installation
Here is the tricky part: for some reason Pop!os uses a different repo for the Nvidia container toolkit, and it never worked for me. To fix this we need to set the priority of the official Nvidia repo higher:
sudo vi /etc/apt/preferences.d/nvidia-docker-pin-1002
Add the following lines here:
Package: *
Pin: origin nvidia.github.io
Pin-Priority: 1002
Then we can follow the Nvidia manual:
Let's create an env var with a distribution name. For Pop!OS 22.04 it is ubuntu22.04
. Change for your distro accordingly
export distribution=ubuntu22.04
The rest is the same as in the instructions:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
echo $distribution
curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.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-docker2
sudo systemctl restart docker
Finally, let's test that it works:
docker run --rm --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
You should see the nvidia-smi output here.
Congratulations! Now you can use docker for all your cuda workloads on Pop!OS.