HomeLinuxThe way to Use the NVIDIA GPU within the Docker Containers on...

The way to Use the NVIDIA GPU within the Docker Containers on Linux Mint 21


You’ll be able to cross via your NVIDIA GPU within the Docker containers and run the CUDA packages in your NVIDIA GPU from these Docker containers. It is a very helpful characteristic to study AI (Synthetic Intelligence). With the ability to run the AI codes (i.e. Tensorflow) on Docker containers will prevent plenty of time. You can even check out your AI codes on totally different CUDA variations without having to alter the CUDA model in your pc.

Fidgeting with NVIDIA drivers and CUDA variations in your pc might trigger issues just like the NVIDIA drivers not working or leaving you with a black/blue display screen of loss of life. So, it’s at all times a good suggestion to go away your system as it’s and make modifications in an remoted surroundings just like the Docker containers. This retains your primary pc clear (of pointless growth instruments).

On this article, we are going to present you the way to set up the Docker CE and NVIDIA docker on Linux Mint 21 in an effort to entry the NVIDIA GPU of your pc from the Docker containers and run the CUDA packages in your NVIDIA GPU.

Matter of Contents:

  1. Checking If the Official NVIDIA GPU Drivers Are Put in on Linux Mint 21
  2. Putting in the Docker CE Dependencies on Linux Mint 21
  3. Putting in the Docker CE GPG Keys on Linux Mint 21
  4. Putting in the Docker CE Repository on Linux Mint 21
  5. Putting in the Docker CE on Linux Mint 21
  6. Including the Linux Mint 21 Login Consumer to the Docker Group
  7. Checking If the Docker CE Is Put in Appropriately on Linux Mint 21
  8. Putting in the NVIDIA Container Toolkit GPG Keys on Linux Mint 21
  9. Putting in the NVIDIA Container Toolkit Repository on Linux Mint 21
  10. Putting in the NVIDIA-DOCKER Drivers on Linux Mint 21
  11. Checking If the NVIDIA GPU Is Accessible from the Docker Containers on Linux Mint 21
  12. Conclusion
  13. References

Checking If the Official NVIDIA GPU Drivers Are Put in on Linux Mint 21

Earlier than you get began, run the next command to confirm that you’ve got an NVIDIA GPU put in in your pc.

On this case, we have now the NVIDIA GTX 1050 Ti GPU put in on our pc. You’ll almost certainly have a distinct NVIDIA GPU put in in your pc.

Additionally, just remember to have the official NVIDIA drivers put in in your Linux Mint 21 working system with the next command:

If the official NVIDIA drivers are put in in your Linux Mint 21 working system, you will notice the next outputs:

Additionally, examine if the official NVIDIA GPU drivers are working with the next command:

If the official NVIDIA GPU drivers are working, you will notice the next outputs. As you may see, we have now the official NVIDIA GPU Driver model 525.78.01 put in on our Linux Mint 21 machine.

For those who don’t have the official NVIDIA GPU drivers put in in your Linux Mint 21 machine and also you want any help with that, please examine the article on The way to Set up the NVIDIA Drivers on Linux Mint 21

Putting in the Docker CE Dependencies on Linux Mint 21

Earlier than you may set up the Docker CE on Linux Mint 21, it’s essential set up the required Docker CE dependency packages on Linux Mint 21.

First, replace the APT bundle repository cache with the next command:

The APT bundle repository cache must be up to date.

To put in the required dependency packages of Docker CE, run the next command:

$ sudo apt-get set up ca-certificates curl gnupg lsb-release

To verify the set up, press Y after which press <Enter>.

The required Docker CE dependency packages must be put in.

Putting in the Docker CE GPG Keys on Linux Mint 21

On this part, we are going to present you the way to set up the GPG key of the Docker CE bundle repository on Linux Mint 21.

First, create a brand new folder which is /and so forth/apt/keyrings with the next command:

$ sudo mkdir -p /and so forth/apt/keyrings

To put in the GPG key of the Docker CE bundle repository on Linux Mint 21, run the next command:

$ curl -fsSL https://obtain.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /and so forth/apt/keyrings/docker.gpg

Putting in the Docker CE Repository on Linux Mint 21

To put in the Docker CE bundle repository on Linux Mint 21, run the next command:

$ echo “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://obtain.docker.com/linux/ubuntu jammy steady” | sudo tee /and so forth/apt/sources.listing.d/docker.listing > /dev/null

Replace the APT bundle repository cache for the modifications to take impact.

Putting in the Docker CE on Linux Mint 21

To put in the most recent model of Docker CE on Linux Mint 21, run the next command:

$ sudo apt-get set up docker-ce docker-ce-cli containerd.io docker-compose-plugin

To verify the set up, press Y after which press <Enter>.

Docker CE and the required dependency packages are being downloaded. It takes some time to finish.

Docker CE and the required dependency packages are being put in. It takes some time to finish.

Docker CE and the required dependency packages must be put in at this level.

Including the Linux Mint 21 Login Consumer to the Docker Group

To create the Docker containers and handle them with out utilizing sudo or logged in as a root consumer, you must add your login consumer to the docker group.

So as to add the login consumer of your Linux Mint 21 to the docker group, run the next command:

$ sudo usermod -aG docker $(whoami)

For the modifications to take impact, restart your pc with the next command:

Checking If the Docker CE Is Put in Appropriately on Linux Mint 21

As soon as your pc begins, run the next command to confirm that you may entry Docker with out superuser privileges:

If all the things works, it’s best to see the next outputs.

As you may see, we’re working the Docker model 20.10.23 – the most recent model of Docker CE on the time of this writing.

Putting in the NVIDIA Container Toolkit GPG Keys on Linux Mint 21

On this part, we are going to present you the way to set up the GPG key of the NVIDIA Container Toolkit bundle repository on Linux Mint 21.

To put in the GPG key of the NVIDIA Container Toolkit bundle repository on Linux Mint 21, run the next command:

$ curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg –dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg

Putting in the NVIDIA Container Toolkit Repository on Linux Mint 21

On this part, we are going to present you the way to set up the NVIDIA Container Toolkit bundle repository on Linux Mint 21.

First, create a brand new APT supply file nvidia-container-toolkit.listing within the /and so forth/apt/sources.listing.d/ listing as follows:

$ sudo nano /and so forth/apt/sources.listing.d/nvidia-container-toolkit.listing

Add the next line within the nvidia-container-toolkit.listing file and press <Ctrl> + X adopted by Y and <Enter> to avoid wasting the file:

deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/steady/ubuntu22.04/$(ARCH) /

For the modifications to take impact, replace the APT bundle repository cache with the next command:

Putting in the NVIDIA-DOCKER Drivers on Linux Mint 21

To put in the NVIDIA Docker drivers on Linux Mint 21, run the next command:

$ sudo apt set up nvidia-docker2

To verify the set up, press Y after which press <Enter>.

The NVIDIA docker drivers must be put in.

For the modifications to take impact, restart your pc with the next command:

Checking If the NVIDIA GPU Is Accessible from the Docker Containers in Linux Mint 21

On this part, we are going to present you the way to create an NVIDIA CUDA Docker container and confirm that the container can entry the NVIDIA GPU out of your pc.

To create an NVIDIA CUDA 12 Docker container based mostly on Ubuntu 20.04 LTS and run the nvidia-smi command in it as soon as it’s created to confirm whether or not it could actually entry the NVIDIA GPU out of your pc, run the next command:

$ docker run –rm –gpus all nvidia/cuda:12.0.0-base-ubuntu20.04 nvidia-smi

Docker is pulling the nvidia/cuda:12.0.0-base-ubuntu20.04 picture from Docker Hub. It takes some time to finish.

As soon as the NVIDIA CUDA docker picture is pulled, a container is created. The nvidia-smi command runs on it and prints the output on the console as you may see within the following screenshot.

As you may see, the Docker container makes use of the NVIDIA GPU driver 525.78.01[1] and the CUDA model 12.0[2]. For those who see comparable outputs, the Docker container can entry the NVIDIA GPU of your pc:

If it’s essential use the older variations of CUDA, examine the nvidia/cuda picture on the Docker Hub.

Conclusion

We confirmed you the way to set up the Docker CE bundle repository on Linux Mint 21. We additionally confirmed you the way to set up the most recent model of Docker CE on Linux Mint 21. We confirmed you the way to set up the NVIDIA Container Toolkit bundle repository on Linux Mint 21 and the way to set up the NVIDIA Docker driver on Linux Mint 21 as effectively. Lastly, we confirmed you the way to entry the NVIDIA GPU of your pc from a Docker container.

References:

  1. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
  2. https://hub.docker.com/r/nvidia/cuda/tags
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments