-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-nvidia.sh
executable file
·47 lines (41 loc) · 1.39 KB
/
install-nvidia.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
#!/bin/bash
set -e
function print-banner () {
local message="$1"
echo "##################################"
echo "$message"
echo "##################################"
}
function pre-installation () {
print-banner "Removing existing NVIDIA packages"
sudo apt-get --purge remove nvidia*
print-banner "Ensuring development kernel"
sudo apt-get install linux-headers-$(uname -r)
print-banner "Downloading installer (*.deb)"
### Working for Nvidia GeForce Titan X
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb \
-O /tmp/cuda.deb
}
function main () {
print-banner "Installing Nvidia Cuda Driver"
sudo dpkg -i /tmp/cuda.deb
print-banner "Accepting key"
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
print-banner "Updating apt list"
sudo apt-get update
print-banner "Installing Nvidia Cuda Driver"
sudo apt-get install cuda
}
function nvidia-docker () {
print-banner "Downloading nvidia-docker"
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
print-banner "Installing Nvidia Docker"
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb
}
if [ "$UID" -ne 0 ] ; then
echo "Please run as root"
else
pre-installation
main "$@"
nvidia-docker
fi