-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_gpu_instance.sh
More file actions
50 lines (44 loc) · 1.88 KB
/
setup_gpu_instance.sh
File metadata and controls
50 lines (44 loc) · 1.88 KB
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
#!/usr/bin/env bash
# This file is for Ubuntu Xenial 16.04
# It installs:
# CUDA 9.0
# cuDNN 7.0
# Python 3.6
# Tensorflow 1.10
# Other combinations may break: https://github.com/tensorflow/tensorflow/issues/15604
# REMINDER: Reboot the instance after running the script
# setup Python3 with pip and venv
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt install python3.6 -y
sudo curl https://bootstrap.pypa.io/get-pip.py | sudo python3.6
sudo apt install python3.6-venv -y
# Install CUDA
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
sudo apt update
sudo apt install cuda -y
echo 'export CUDA_HOME=/usr/local/cuda' >> ~/.bashrc
echo 'export PATH=$PATH:$CUDA_HOME/bin' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$CUDA_HOME/lib64' >> ~/.bashrc
source ~/.bashrc
# Install cuDNN / https://developer.nvidia.com/rdp/cudnn-download
gsutil cp gs://nachbarstrom-cudnn-drivers/cudnn-9.0-linux-x64-v7.tgz .
tar -xzvf cudnn-9.0-linux-x64-v7.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
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 cudnn-9.0-linux-x64-v7.tgz
rm -rf cuda/
# Install Tensorflow-GPU
python3.6 -m venv env
source env/bin/activate
python3.6 -m pip install tensorflow-gpu==1.10 -y
# Install and configure jupyter
python3.6 -m pip install jupyter -y
$(which jupyter) notebook --generate-config
echo "c = get_config()" >> $HOME/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.ip = '*'" >> $HOME/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False" >> $HOME/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.port = 8888" >> $HOME/.jupyter/jupyter_notebook_config.py