-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_cuda.sh
70 lines (64 loc) · 2.42 KB
/
setup_cuda.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
#!/usr/bin/env bash
set -e
CUDA_PATH="/usr/local/cuda-$CUDA_VERSION"
# Setup Cuda URL
if [ "$CUDA_VERSION" = "9.0" ]; then
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run"
elif [ "$CUDA_VERSION" = "9.1" ]; then
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux"
elif [ "$CUDA_VERSION" = "9.2" ]; then
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda_9.2.88_396.26_linux"
else
echo "Error: You need to set CUDA_VERSION to 9.0, 9.1 or 9.2."
exit -1
fi
# Setup cuDNN URL
if [ "$CUDNN_VERSION" = "7.4" ]; then
if [ "$CUDA_VERSION" = "9.0" ]; then
CUDNN_VERSION_DETAILED="7.4.1.5"
#elif [ "$CUDA_VERSION" = "9.1" ]; then
# CUDNN_VERSION_DETAILED="7.0.5.15"
#elif [ "$CUDA_VERSION" = "9.2" ]; then
# echo "Error: CUDNN 7.0 is not compatible with CUDA 9.2."
# exit -1
fi
elif [ "$CUDNN_VERSION" = "7.1" ]; then
if [ "$CUDA_VERSION" = "9.0" ]; then
CUDNN_VERSION_DETAILED="7.1.4.18"
elif [ "$CUDA_VERSION" = "9.1" ]; then
CUDNN_VERSION_DETAILED="7.1.3.16"
elif [ "$CUDA_VERSION" = "9.2" ]; then
CUDNN_VERSION_DETAILED="7.1.4.18"
fi
else
echo "Error: You need to set CUDNN_VERSION to 7.0 or 7.1."
exit -1
fi
CUDNN_URL="https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_${CUDNN_VERSION_DETAILED}-1+cuda${CUDA_VERSION}_amd64.deb"
CUDNN_URL_DEV="https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_${CUDNN_VERSION_DETAILED}-1+cuda${CUDA_VERSION}_amd64.deb"
# Install Cuda
wget $CUDA_URL -O "/tmp/cuda.run"
bash "/tmp/cuda.run" --silent --toolkit --override --toolkitpath $CUDA_PATH
rm -f "/tmp/cuda.run"
ln -s $CUDA_PATH "$(dirname $CUDA_PATH)/cuda/"
# Install cuDNN .so files
wget $CUDNN_URL -O "/tmp/cudnn.deb"
mkdir /tmp/cudnn
cd /tmp/cudnn
ar x ../cudnn.deb
tar -xJf data.tar.xz
mv usr/lib/x86_64-linux-gnu/libcudnn* $CUDA_PATH/lib64/
rm -fr /tmp/cudnn
rm -f /tmp/cudnn.deb
cd /
# Install cuDNN .h and static lib files
wget $CUDNN_URL_DEV -O "/tmp/cudnn.deb"
mkdir /tmp/cudnn
cd /tmp/cudnn
ar x ../cudnn.deb
tar -xJf data.tar.xz
mv usr/include/x86_64-linux-gnu/cudnn_v7.h $CUDA_PATH/include/cudnn.h
mv usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a $CUDA_PATH/lib64/libcudnn_static.a
rm -fr /tmp/cudnn
rm -f /tmp/cudnn.deb
cd /