├── README.md └── setup-aws-tensorflow.bash /README.md: -------------------------------------------------------------------------------- 1 | # Setting up TensorFlow 0.9 with Python 3.5 on AWS GPU-instance 2 | 3 | ## Description 4 | 5 | `setup-aws-tensorflow.bash` installs the following things on the ec2 `g2.2xlarge` instance running Ubuntu 14.04: 6 | 7 | - Required linux packages 8 | - CUDA 7.5 9 | - cuDNN v4 10 | - Anaconda with Python 3.5 11 | - TensorFlow 0.9 12 | - GPU usage tool `gpustat` 13 | 14 | It is based on the blog post: . 15 | 16 | ## Usage 17 | 18 | Just run `setup_aws_tensorflow.bash` on the aws instance: 19 | 20 | ```bash 21 | ./setup_aws_tensorflow.bash 22 | ``` 23 | 24 | -------------------------------------------------------------------------------- /setup-aws-tensorflow.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # stop on error 4 | set -e 5 | ############################################ 6 | # install into /mnt/bin 7 | sudo mkdir -p /mnt/bin 8 | sudo chown ubuntu:ubuntu /mnt/bin 9 | 10 | # install the required packages 11 | sudo apt-get update && sudo apt-get -y upgrade 12 | sudo apt-get -y install linux-headers-$(uname -r) linux-image-extra-`uname -r` 13 | 14 | # install cuda 15 | wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.5-18_amd64.deb 16 | sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb 17 | rm cuda-repo-ubuntu1404_7.5-18_amd64.deb 18 | sudo apt-get update 19 | sudo apt-get install -y cuda 20 | 21 | # get cudnn 22 | CUDNN_FILE=cudnn-7.0-linux-x64-v4.0-prod.tgz 23 | wget http://developer.download.nvidia.com/compute/redist/cudnn/v4/${CUDNN_FILE} 24 | tar xvzf ${CUDNN_FILE} 25 | rm ${CUDNN_FILE} 26 | sudo cp cuda/include/cudnn.h /usr/local/cuda/include # move library files to /usr/local/cuda 27 | sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 28 | sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* 29 | rm -rf cuda 30 | 31 | # set the appropriate library path 32 | echo 'export CUDA_HOME=/usr/local/cuda 33 | export CUDA_ROOT=/usr/local/cuda 34 | export PATH=$PATH:$CUDA_ROOT/bin:$HOME/bin 35 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64 36 | ' >> ~/.bashrc 37 | 38 | # install anaconda 39 | wget http://repo.continuum.io/archive/Anaconda3-4.0.0-Linux-x86_64.sh 40 | bash Anaconda3-4.0.0-Linux-x86_64.sh -b -p /mnt/bin/anaconda3 41 | rm Anaconda3-4.0.0-Linux-x86_64.sh 42 | echo 'export PATH="/mnt/bin/anaconda3/bin:$PATH"' >> ~/.bashrc 43 | 44 | # install tensorflow 45 | export TF_BINARY_URL='https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.9.0rc0-cp35-cp35m-linux_x86_64.whl' 46 | 47 | /mnt/bin/anaconda3/bin/pip install $TF_BINARY_URL 48 | 49 | # install monitoring programs 50 | sudo wget https://git.io/gpustat.py -O /usr/local/bin/gpustat 51 | sudo chmod +x /usr/local/bin/gpustat 52 | sudo nvidia-smi daemon 53 | sudo apt-get -y install htop 54 | 55 | # reload .bashrc 56 | exec bash 57 | ############################################ 58 | # run the test 59 | # byobu # start byobu + press Ctrl + F2 60 | # htop # run in window 1, press Shift + F2 61 | # watch --color -n1.0 gpustat -cp # run in window 2, press Shift + 62 | # wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/models/image/mnist/convolutional.py 63 | # python convolutional.py # run in window 3 64 | --------------------------------------------------------------------------------