Access Nvidia gpu inside docker container in Arch linux

Why

If you need gpu acceleration in a container or just have too much free time on your hands, you can run all kinds of things. For example Large Language Models or GUI apps.
You can even create your own gpu accelerated docker image by usin…


This content originally appeared on DEV Community and was authored by Open Sauce Projects

Why

  • If you need gpu acceleration in a container or just have too much free time on your hands, you can run all kinds of things. For example Large Language Models or GUI apps.
  • You can even create your own gpu accelerated docker image by using Nvidia ubuntu images

How

  • We have to install the NVIDIA Container Toolkit
  • The package can be installed from the Extras repository

    sudo pacman -S nvidia-container-toolkit
    
  1. Configure the container runtime by using the nvidia-ctk command. The nvidia-ctk command modifies the /etc/docker/daemon.json file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime.

    sudo nvidia-ctk runtime configure --runtime=docker
    
  2. For the change to take effect we have to restart the docker daemon.

    sudo systemctl restart docker
    
  3. You can add the gpu using docker compose:

    service_name:
      image: ....
      deploy:
        resources:
          reservations:
            devices:
              - driver: nvidia
                count: 1
                capabilities: [gpu]
    

    If you use the docker run command, you can do:

    sudo docker run --runtime=nvidia --gpus all ....
    

Resources


This content originally appeared on DEV Community and was authored by Open Sauce Projects


Print Share Comment Cite Upload Translate Updates
APA

Open Sauce Projects | Sciencx (2024-08-24T00:19:03+00:00) Access Nvidia gpu inside docker container in Arch linux. Retrieved from https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/

MLA
" » Access Nvidia gpu inside docker container in Arch linux." Open Sauce Projects | Sciencx - Saturday August 24, 2024, https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/
HARVARD
Open Sauce Projects | Sciencx Saturday August 24, 2024 » Access Nvidia gpu inside docker container in Arch linux., viewed ,<https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/>
VANCOUVER
Open Sauce Projects | Sciencx - » Access Nvidia gpu inside docker container in Arch linux. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/
CHICAGO
" » Access Nvidia gpu inside docker container in Arch linux." Open Sauce Projects | Sciencx - Accessed . https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/
IEEE
" » Access Nvidia gpu inside docker container in Arch linux." Open Sauce Projects | Sciencx [Online]. Available: https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/. [Accessed: ]
rf:citation
» Access Nvidia gpu inside docker container in Arch linux | Open Sauce Projects | Sciencx | https://www.scien.cx/2024/08/24/access-nvidia-gpu-inside-docker-container-in-arch-linux/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.