forked from Avsecz/aws-tensorflow-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-aws-tensorflow.bash
executable file
·105 lines (86 loc) · 2.96 KB
/
setup-aws-tensorflow.bash
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
#!/bin/bash
# stop on error
set -e
############################################
# install into /mnt/bin
sudo mkdir -p /mnt/bin
sudo chown ubuntu:ubuntu /mnt/bin
# install the required packages
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get -y install linux-headers-$(uname -r) linux-image-extra-`uname -r`
sudo apt-get -y install git
sudo apt-get -y install mosh
sudo apt-get -y install awscli
sudo apt-get -y install unzip
sudo apt-get -y install zram-config
# install cuda
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb
rm cuda-repo-ubuntu1404_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install -y cuda
# get cudnn
CUDNN_FILE=cudnn-7.5-linux-x64-v5.1.tgz
wget http://developer.download.nvidia.com/compute/redist/cudnn/v5.1/${CUDNN_FILE}
tar xvzf ${CUDNN_FILE}
rm ${CUDNN_FILE}
sudo cp cuda/include/cudnn.h /usr/local/cuda/include # move library files to /usr/local/cuda
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
rm -rf cuda
# set the appropriate library path
echo 'export CUDA_HOME=/usr/local/cuda
export CUDA_ROOT=/usr/local/cuda
export PATH=$PATH:$CUDA_ROOT/bin:$HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64
' >> ~/.bashrc
# install anaconda
wget https://repo.continuum.io/archive/Anaconda2-4.1.1-Linux-x86_64.sh
bash Anaconda2-4.1.1-Linux-x86_64.sh -b -p /mnt/bin/anaconda2
rm Anaconda2-4.1.1-Linux-x86_64.sh
echo 'export PATH="/mnt/bin/anaconda2/bin:$PATH"' >> ~/.bashrc
# install tensorflow
export TF_BINARY_URL='https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0rc0-cp27-none-linux_x86_64.whl'
/mnt/bin/anaconda2/bin/pip install $TF_BINARY_URL
# install theano
/mnt/bin/anaconda2/bin/pip install --upgrade --no-deps git+https://github.com/Theano/Theano.git
# install keras
/mnt/bin/anaconda2/bin/pip install --upgrade --no-deps git+https://github.com/fchollet/keras.git
# configure keras
mkdir ~/.keras/
echo '{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}' > ~/.keras/keras.json
# configure theano
echo '[global]
device = gpu
force_device = True
floatX = float32
allow_gc = False
mode = FAST_RUN
[DebugMode]
check_finite = 1
[lib]
cnmem = 1
[dnn]
enabled = True
[nvcc]
fastmath = True
' > ~/.theanorc
# install monitoring programs
sudo wget https://git.io/gpustat.py -O /usr/local/bin/gpustat
sudo chmod +x /usr/local/bin/gpustat
sudo nvidia-smi daemon
sudo apt-get -y install htop
# reload .bashrc
exec bash
############################################
# run the test
# byobu # start byobu + press Ctrl + F2
# htop # run in window 1, press Shift + F2
# watch --color -n1.0 gpustat -cp # run in window 2, press Shift + <left>
# wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/models/image/mnist/convolutional.py
# python convolutional.py # run in window 3