Skip to content

flavienbwk/nvidia-cuda-mirror-docker

Repository files navigation

nvidia-cuda-mirror-docker

Want to have fun with NVIDIA Docker ? This repository allows you to easily setup an NVIDIA Docker mirror that retrieves the following libraries :

Downloading & updating

Run the mirror container :

docker-compose build
docker-compose up mirror

Expected size : 1.5 Go

Serving

Run the server :

docker-compose up -d server

Server will run on localhost:8080

Client configuration

You must have Docker >= 18 installed on your system before starting.

If you use another distro than the one below, you'll have to configure your package configuration accordingly.

Ubuntu 18.04

Download the appropriate NVIDIA drivers for your card and execute it with sh

Create the /etc/apt/sources.list.d/nvidia-cuda-docker-mirror.list file :

sudo bash -c "{
    echo 'deb http://localhost:8080/libnvidia-container/ubuntu18.04/amd64 /'
    echo 'deb http://localhost:8080/nvidia-container-runtime/ubuntu18.04/amd64 /'
    echo 'deb http://localhost:8080/nvidia-docker/ubuntu18.04/amd64 /'
} >> /etc/apt/sources.list.d/nvidia-cuda-docker-mirror.list"

You may just want to copy past the content to some other file :

deb http://localhost:8080/libnvidia-container/ubuntu18.04/amd64 /
deb http://localhost:8080/nvidia-container-runtime/ubuntu18.04/amd64 /
deb http://localhost:8080/nvidia-docker/ubuntu18.04/amd64 /

You'll have to import the gpgkey available at the root of the mirror :

curl -s -L http://localhost:8080/gpgkey | sudo apt-key add -

You can now :

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

CentOS 7

You may want to follow cyberciti.biz's tutorial to install nvidia-smi or see the TL;DR below

NVIDIA kernel configuration and install instructions
# After configuring your ElRepo and EPEL repositories
sudo yum group install "Development Tools"
sudo yum install kernel-devel
sudo yum -y install epel-release
sudo yum -y install dkms

In the /etc/default/grub file, append the following line to the GRUB_CMDLINE_LINUX property :

rd.driver.blacklist=nouveau nouveau.modeset=0

And then run :

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo bash -c "echo 'blacklist nouveau' > /etc/modprobe.d/blacklist-nouveau.conf" 
sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
sudo dracut /boot/initramfs-$(uname -r).img $(uname -r)
sudo reboot

Once rebooted :

Download the appropriate NVIDIA drivers for your card and execute it with sh

sudo systemctl isolate multi-user.target
sudo sh NVIDIA-Linux-x86_64-*.run
sudo reboot

Create a /etc/yum.repos.d/nvidia-cuda-docker-mirror.repo file :

[mymirror-nvidia-libnvidia-container]
name=My Centos libnvidia-container Nvidia local mirror
baseurl=http://localhost:8080/libnvidia-container/centos7/$basearch/
gpgkey=http://localhost:8080/gpgkey
repo_gpgcheck=1
gpgcheck=0
enabled=1

[mymirror-nvidia-container-runtime]
name=My Centos Nvidia container runtime local mirror
baseurl=http://localhost:8080/nvidia-container-runtime/centos7/$basearch/
gpgkey=http://localhost:8080/gpgkey
repo_gpgcheck=1
gpgcheck=0
enabled=1

[mymirror-nvidia-docker]
name=My Centos Nvidia Docker local mirror
baseurl=http://localhost:8080/nvidia-docker/centos7/$basearch/
gpgkey=http://localhost:8080/gpgkey
repo_gpgcheck=1
gpgcheck=0
enabled=1

You can now :

sudo yum update
sudo yum install nvidia-docker2

Docker configuration annexe

After installing nvidia-docker2, configure your /etc/docker/daemon.json conf file to use the NVIDIA container runtime :

{
    "runtimes": {
        "nvidia": {
            "path": "nvidia-container-runtime",
            "runtimeArgs": []
        }
    },
    "default-runtime": "nvidia"
}

You'll probably need a reboot. You can try your install by running :

docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

Notes

👉 Please cite my work if you're using it !
👉 Feel free to send pull requests !