-
Notifications
You must be signed in to change notification settings - Fork 5
/
installCudaCuDNN.sh
executable file
·80 lines (73 loc) · 2.68 KB
/
installCudaCuDNN.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
#!/bin/bash
function cudaInstall()
{
#create temp dir
CUR_PATH=$(pwd)
mkdir -p -v $CUR_PATH/temp
tempPath="$CUR_PATH/temp"
cd $tempPath
if [ ! -f rebootFlag ]; then
if [ ! -f cuda_9.0.176_384.81_linux-run ]; then
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
fi
chmod +x cuda_9.0.176_384.81_linux-run
./cuda_9.0.176_384.81_linux-run --extract=$tempPath
pwd
sudo ./cuda-linux.9.0.176-22781540.run
read -r -p "Do you wanna verify our CUDA Installation?[Y/N]" response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
touch verifyFlag
sudo ./cuda-samples.9.0.176-22781540-linux.run
else
echo "Skipping, CUDA verfication"
fi
#configure the runtime library
sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig
touch rebootFlag
echo "Note:"
echo "Update the below steps manually:"
echo "$ sudo vim /etc/environment"
echo "add :/usr/local/cuda/bin (including the ":") at the end of the"
echo "###############################################################"
echo "######## The above installation requires reboot or Logout user###############"
echo "Reboot the system and run the same script"
exit 1
else
echo "######## Running POST Process of CUDA Installation ############"
if [ -f verifyFlag ]; then
cd /usr/local/cuda-9.0/samples
sudo make
cd /usr/local/cuda/samples/bin/x86_64/linux/release
./deviceQuery
else
echo "Skipping, CUDA verfication"
fi
fi
}
function cuDNNInstall()
{
echo "Download libcudnn7_7.0.5.15–1+cuda9.0_amd64.deb, libcudnn7-dev_7.0.5.15–1+cuda9.0_amd64.deb and
libcudnn7-doc_7.0.5.15–1+cuda9.0_amd64.deb from https://developer.nvidia.com/rdp/cudnn-download"
echo "Need Nvidia Reg"
read -r -p "Give a download path of cuDNN?[Y/N]" cuDNNPath
pushd $cuDNNPath
sudo dpkg -i libcudnn7*.deb
popd
#Configure the CUDA and cuDNN library paths
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64"' >> ~/.bashrc
source ~/.bashrc
}
function verifyCuda()
{
pip install --upgrade future --user
pip install --upgrade tensorflow-gpu --user
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
}
#MainStarts Here
cudaInstall
cuDNNInstall
verifyCuda
#Remove the temp dir, After successfull installation
rm -rf $CUR_PATH/temp