-
Notifications
You must be signed in to change notification settings - Fork 1
/
nvidia41078mb.sh
282 lines (240 loc) · 9.91 KB
/
nvidia41078mb.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/bash
# nvidia41078mb.sh
# Michael McMahon
# This script installs proprietary NVIDIA drivers 410.78 and CUDA toolkit
# for motherboard video output.
# To run this script, boot into your GNU/Linux distro with runlevel 2 or 3.
# Follow these instructions:
# Run this script with:
# sudo bash nvidia41078mb.sh
# OR
# su
# bash nvidia41078mb.sh
# OR
# sudo chmod 755 nvidia41078mb.sh
# sudo ./nvidia41078mb.sh
# OR
# su
# chmod 755 nvidia41078mb.sh
# ./nvidia41078mb.sh
# Prerequisites for this script:
#
# 0. On Supermicro boards, set the JPG1 pin to the 1-2 setting to enable the
# BIOS to switch between Video Output modes.
#
# In BIOS, make sure Advanced > PCIe/PCI/PnP Configuration > VGA Priority is
# set to ```Onboard```. This option should only be used when remotely
# controlling the system over IPMI as CUDA performance suffers compared to
# testing with ```Offboard``` and NVIDIA#####gpu.sh driver installation
# method.
#
# 1. Install the system (with Compatibility Libraries and Development Tools or
# build-essential if applicable)
#
# 2. Update all software
# # CentOS / Scientific Linux
# su
# yum update -y
#
# # Fedora
# dnf -y update
#
# # Debian based systems
# sudo apt update && sudo apt upgrade -y && sudo apt-get dist-upgrade -y
#
# 3. Install Compatibility Libraries and Development Tools or build-essential
# # CentOS / Scientific Linux 6
# yum groupinstall -y Development\ Tools
# yum groupinstall -y Compatibility\ Libraries
#
# # CentOS / Scientific Linux 7
# yum groups install -y Development\ Tools
# yum groups install -y Compatibility\ Libraries
#
# # Debian based systems
# sudo apt install -y ledmon build-essential
#
# 4. Boot into the correct runlevel with nomodeset rdblacklist nouveau
# Reboot and edit grub temporarily (press arrow keys
# up and down repeatedly during boot)
# Press 'e' on the top entry to edit temporarily. Edit the line that starts
# with linux. Add these entries around words like 'ro quiet':
# nomodeset rdblacklist nouveau 3
# Note: Ubuntu Desktop requires editing /etc/default/grub and running
# update-grub or backing up and editing /boot/grub/grub.cfg with:
# nomodeset rdblacklist nouveau 2 text
#
# 5. Run this script.
# sudo bash nvidia41078mb.sh
#
# 6. Reboot and verify that all cards are working by running:
# nvidia-smi
#
# If kernel headers are missing, install the kernel headers for your kernel.
# Debian based systems: sudo apt install -y linux-headers-$(uname -r)
# Red Hat based systems: yum install -y kernel-devel
#
# Initialization checks
# Check for /bin/bash.
if [ "$BASH_VERSION" = '' ]; then
echo "You are not using bash."
echo "Use this syntax instead:"
echo "sudo bash nvidia41078mb.sh"
exit 1
fi
# Check for root.
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root!"
exit 1
fi
# Check networking
# https://unix.stackexchange.com/questions/190513
echo Checking network...
if ping -q -c 1 -W 1 google.com >/dev/null; then
echo "The network is up."
else
echo "The network is down."
echo "Check connection and restart script!"
exit 1
fi
if [[ $(runlevel | awk '{ print $2 }') -gt 3 ]]; then
echo "Runlevel is greater than 3"
echo "Reboot and edit grub temporarily (press arrow keys up and down"
echo "repeatedly during boot)"
echo "Press 'e' on the top entry to edit temporarily. Edit the line that"
echo "starts with linux. Add these entries around words like 'ro quiet':"
echo " nomodeset rdblacklist nouveau 3"
exit 1
fi
# Log all stdout to logfile with date.
logfile=/tmp/$(date +%Y%m%d-%H%M).log
exec &> >(tee -a "$logfile")
echo Starting logfile as $logfile...
echo \
echo "Temporarily removing nouvea..."
modprobe -r nouveau
echo "Changing into the /tmp directory..."
cd /tmp
echo "This script currently works with GPU video output for"
echo "RPM or DEB workflows after you have properly booted."
# Downloading
echo "Downloading proprietary NVIDIA drivers from NVIDIA..."
# wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/NVIDIA-Linux-x86_64-410.78.run
wget -q http://us.download.nvidia.com/XFree86/Linux-x86_64/410.78/NVIDIA-Linux-x86_64-410.78.run
echo "Downloading proprietary CUDA toolkit from NVIDIA..."
date
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.0.176_384.81_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.0.176.1_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.0.176.2_linux.run
wget -q http://developer2.download.nvidia.com/compute/cuda/9.0/secure/Prod/local_installers/cuda_9.0.176_384.81_linux.run
wget -q http://developer.download.nvidia.com/compute/cuda/9.0/secure/Prod/patches/1/cuda_9.0.176.1_linux.run
wget -q http://developer.download.nvidia.com/compute/cuda/9.0/secure/Prod/patches/2/cuda_9.0.176.2_linux.run
wget -q http://developer.download.nvidia.com/compute/cuda/9.0/secure/Prod/patches/2/cuda_9.0.176.3_linux.run
wget -q http://developer.download.nvidia.com/compute/cuda/9.0/secure/Prod/patches/2/cuda_9.0.176.4_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.1.85_387.26_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.1.85.1_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.1.85.2_linux.run
#wget -q ftp://10.12.17.15/pub/software/drivers/nvidia/cuda/cuda_9.1.85.3_linux.run
# wget -q http://developer2.download.nvidia.com/compute/cuda/9.0/secure/Prod/local_installers/cuda_9.1.85_387.26_linux.run
# wget -q http://developer.download.nvidia.com/compute/cuda/9.1/secure/Prod/patches/1/cuda_9.1.85.1_linux.run
# wget -q http://developer.download.nvidia.com/compute/cuda/9.1/secure/Prod/patches/2/cuda_9.1.85.2_linux.run
# wget -q http://developer.download.nvidia.com/compute/cuda/9.1/secure/Prod/patches/3/cuda_9.1.85.3_linux.run
date
# Installing NVIDIA
# To learn more about the available switches, see http://www.manpages.spotlynx.com/gnu_linux/man/nvidia-installer.1 or run:
# sh NVIDIA-Linux-x86_64-XXX.XX.run --help
echo "Installing proprietary NVIDIA drivers..."
echo "Attempting to installing dkms..."
yum install -y epel-release 2>/dev/null
yum install -y dkms 2>/dev/null
yum install -y kernel-devel 2>/dev/null
dnf install -y dkms 2>/dev/null
apt-get update 2>/dev/null
apt-get install -y dkms 2>/dev/null
echo "Installing proprietary NVIDIA drivers..."
# If dkms is not installed, do not use the dkms switch.
if [[ $(which dkms | wc -l) -gt 0 ]]; then
sh NVIDIA-Linux-x86_64-410.78.run --accept-license -q --dkms --no-opengl-files
else
sh NVIDIA-Linux-x86_64-410.78.run --accept-license -q --no-opengl-files
fi
echo \
echo "Warnings about 32 bit libraries are OK."
echo "If any messages concern you, check the logs at"
echo " /var/log/nvidia-installer.log"
echo \
# If RPM based distro 6.x, the NVIDIA installer will fail. Use CTRL+C to close
# the installer. Let the cuda install finish. Manually run the NVIDIA
# installer.
# sh NVIDIA-Linux-x86_64-410.78.run --accept-license -q -X
# To update NVIDIA drivers on a system that already has proprietary NVIDIA
# drivers, use:
# nvidia-installer --update
# Installing CUDA
# To learn more about the available switches, run:
# sh cuda_X.X.XX_XXX.XX_linux-run --help
# Installing Cuda 9.0 instead of 9.1 for compatibility with TensorFlow.
echo "Installing proprietary CUDA toolkit..."
sh cuda_9.0.176_384.81_linux.run --toolkit --silent --override
#sh cuda_9.1.85_387.26_linux.run --toolkit --silent --override
# Installing CUDA patches
echo "Installing CUDA patches..."
sh cuda_9.0.176.1_linux.run --accept-eula -silent
sh cuda_9.0.176.2_linux.run --accept-eula -silent
sh cuda_9.0.176.3_linux.run --accept-eula -silent
sh cuda_9.0.176.4_linux.run --accept-eula -silent
#sh cuda_9.1.85.1_linux.run --accept-eula -silent
#sh cuda_9.1.85.2_linux.run --accept-eula -silent
#sh cuda_9.1.85.3_linux.run --accept-eula -silent
echo "Adding CUDA to the PATH..."
if [[ $(cat /etc/bashrc | grep cuda | wc -l) -eq 0 ]] && [ $(ls /etc/bashrc | wc -l) -gt 0 ]; then
echo export 'PATH=/usr/local/cuda/bin:$PATH' >> /etc/bashrc
fi
if [[ $(cat /etc/bash.bashrc | grep cuda | wc -l) -eq 0 ]] && [ $(ls /etc/bash.bashrc | wc -l) -gt 0 ]; then
echo export 'PATH=/usr/local/cuda/bin:$PATH' >> /etc/bash.bashrc
fi
echo "Adding CUDA libs to the ld.so.conf..."
if [[ $(cat /etc/default/grub | grep cuda | wc -l) -eq 0 ]]; then
echo /usr/local/cuda/lib64 >> /etc/ld.so.conf
echo /usr/local/cuda/lib >> /etc/ld.so.conf
fi
if [[ $(cat /etc/udev/rules.d/98-nvstusb.rules | wc -l) -eq 0 ]]; then
echo "Creating udev rules for 3D Vision USB IR emitter..."
echo "# NVIDIA 3D Vision USB IR Emitter" > /etc/udev/rules.d/98-nvstusb.rules
echo "# From http://users.csc.calpoly.edu/~zwood/teaching/csc572/final11/rsomers/" >> /etc/udev/rules.d/98-nvstusb.rules
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0955", ATTR{idProduct}=="7003", MODE="0666"' >> /etc/udev/rules.d/98-nvstusb.rules
fi
echo "Blacklisting nouveau driver..."
if [[ $(cat /etc/modprobe.d/blacklist.conf | grep nouveau | wc -l) -eq 0 ]]; then
echo blacklist nouveau >> /etc/modprobe.d/blacklist.conf
echo blacklist lbm-nouveau >> /etc/modprobe.d/blacklist.conf
fi
echo "Executing dracut..."
dracut -f 2>/dev/null
echo "Executing ldconfig..."
ldconfig
if [[ $((lsb_release -a 2>/dev/null | grep -i Ubuntu | wc -l)) -gt 0 ]]; then
echo "Updating initramfs for Ubuntu 17.10"
rmmod nouveau
update-initramfs -u
update-grub
fi
# Log details
echo "All temporary installers, scripts, and logs can be found"
echo "in the /tmp/ folder."
uptime
echo "Log saved to $logfile"
echo \
# Post install check
echo "Running nvidia-smi..."
nvidia-smi
echo "If nvidia-smi fails to load or all of the video cards are not listed"
echo "above, the installer may have ran into a problem. Check the"
echo "/var/log/nvidia-installer.log file for help and more details."
echo \
echo "Reboot and check nvidia-smi again to ensure the install succeeded."
echo \
# SBGrid 3D Workstation orders
echo "Systems with NVIDIA 3D Vision Glasses must also run:"
echo " nvidia-xconfig --stereo=11"
echo \