-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_gpu_install.sh
86 lines (70 loc) · 2.85 KB
/
docker_gpu_install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Installs latest docker and nvidia toolkit to enable gpu acces inside of containers
echo installing docker for Ubuntu, as per https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt update && sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
apt-cache policy docker-ce
sudo apt-get install docker-ce docker-ce-cli containerd.io
echo install complete, now checking if successful
sudo systemctl status docker
sudo docker run hello-world
# To allow your user to run docker commands then execute the following, else only root has access
echo adding ${USER} to the docker group
sudo usermod -aG docker ${USER}
echo installing nvidia toolkit, as per https://github.com/NVIDIA/nvidia-docker
# Add the package repositories
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
sudo systemctl status docker
echo testing nvidia toolkit, output of nvidia-smi should show
docker run --rm --gpus all nvidia/cuda:10.0-base nvidia-smi
# To change the default runtime to nvidi-container-runtime to grant gpu access during docker build
sudo tee /etc/docker/daemon.json <<EOF
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
EOF
sudo pkill -SIGHUP dockerd
sudo apt-get install nvidia-container-runtime
sudo systemctl restart docker.service
exit 0
#For an arch install use the following
sudo pacman -S docker
sudo systemctl start docker
sudo systemctl status docker
# To allow your user to run docker commands then execute the following, else only root has access
echo adding ${USER} to the docker group
sudo usermod -aG docker ${USER}
# Test docker install
docker run hello-world
# Nvidia tookit install
echo ensure nvidia drivers are up to date
yay -S libnvidia-container
yay -S nvidia-container-toolkit
docker run --rm --gpus all nvidia/cuda:10.0-base nvidia-smi
# To change the default runtime to nvidi-container-runtime to grant gpu access during docker build
sudo tee /etc/docker/daemon.json <<EOF
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
EOF
sudo systemctl stop docker.service
sudo pkill -SIGHUP dockerd
yay -S nvidia-container-runtime
sudo systemctl restart docker.service