In today's article, I will try to explain Pardus what is nvidia docker2 and how to install it on our system.
Nvidia Docker 2 is a tool for running docker containers using Nvidia GPUs. This tool uses Nvidia GPUs directly in docker containers, allowing GPU-intensive workloads such as machine learning and deep learning to run more efficiently.
In this way, we can perform different operations on a single device using docker containers. For example, for a project, we can run libraries of different versions in different containers instead of different systems.
For installation, first of all, nvidia drivers must be installed on our system to install nvidia docker2. For this topic on the forum You can look at it and then of course we must have docker installed on our system. For this, we can use the version in Pardus repositories directly, or we can add and use the repositories provided by Docker itself.
Installing Docker from Pardus repository
If the version in Pardus repositories is sufficient for you, you can perform the installation process by following the steps below.
Warning
You have to enter your own username where your username is below!
sudo apt update sudo apt install docker.io sudo usermod -aG docker your user_name #you need to enter your own username here sudo systemctl restart docker
Installing Docker from its own repository
If you don't want to have a version problem, you can use docker's own repositories. Especially when creating customized images, yaml files can have problems.
To install, we first install the necessary packages
sudo apt-get update sudo apt-get install ca-certificates curl gnupg
We add official keys to the system
sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
We add the repository to the system
echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ bullseye stable" | \ sudo tee /etc/apt/sources.list.d/docker2.list > /dev/null
And we install the docker with its tools
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
In addition, we can add docker to the system as a super user. In this way, we always sudo
It does not ask for our password.
Warning
You have to enter your own username where your username is below!
sudo usermod -aG docker your username sudo systemctl restart docker
instructions here on docker's own site some parts were adapted to Pardusa. For example
"$(. /etc/os-release && echo "$VERSION_CODENAME")"
Here pardus in docker twenty one This part because there is no repository for bullseye I changed it to. We will have to do this part a little differently for nvidia-docker2 at the bottom. But you don't need to change anything. I have already set the sections in the article.
Nvidia docker2 installation
First, we add the repository to our system with the key.
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/debian11/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
To install
sudo apt-get update sudo apt-get install -y nvidia-docker2 sudo systemctl restart docker
Insha'Allah, if there is no problem, nvidia-docker2 should be installed on your system now. good luck now
You can try below trial CUDA container for testing
sudo docker run --rm --runtime=nvidia --gpus all nvidia/cuda:11.6.2-base-ubuntu20.04 nvidia-smi
As a result, you should get a result similar to nvidia's own site.

Kaynaklar:
https://docs.docker.com/engine/install/debian/
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
https://gonullu.pardus.org.tr/docker-kullanarak-gui-uygulama-calistirma/