Last active
May 23, 2018 01:10
-
-
Save chaser92/3f50d75170050abc3cb463b2be04262b to your computer and use it in GitHub Desktop.
Install TensorFlow and Anaconda on an Amazon EC2 P2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEFORE STARTING PUT libcudnn5_5.1.10-1+cuda8.0_amd64.deb AND libcudnn5-dev_5.1.10-1+cuda8.0_amd64.deb IN /tmp | |
# OTHERWISE THIS WON'T WORK | |
# This has been tested only on EC2 P2 xlarge instance with 16 GB storage and stock Ubuntu 16.04 | |
# It's a setup for a playground EC2 machine to perform workshops with Jupyter Notebook on GPU. | |
# It might contain some unnecessary crap | |
# The process takes like 15 minutes | |
pushd /tmp && | |
stat libcudnn5_5.1.10-1+cuda8.0_amd64.deb && | |
stat libcudnn5-dev_5.1.10-1+cuda8.0_amd64.deb && | |
echo "export LC_ALL=\"en_US.UTF-8\"" > ~/.profile && | |
echo "export LC_CTYPE=\"en_US.UTF-8\"" > ~/.profile && | |
echo "export PATH=/home/ubuntu/anaconda3/bin:\$PATH" >> ~/.profile && | |
source ~/.profile && | |
sudo dpkg-reconfigure --frontend=noninteractive locales && | |
sudo apt-get update && | |
sudo apt-get upgrade -y && | |
sudo apt-get install -y build-essential git libfreetype6-dev \ | |
libxft-dev libncurses-dev libopenblas-dev gfortran libblas-dev \ | |
liblapack-dev libatlas-base-dev python-dev linux-headers-generic \ | |
linux-image-extra-virtual unzip swig unzip \ | |
wget pkg-config zip g++ zlib1g-dev libcurl3-dev && | |
wget https://repo.continuum.io/archive/Anaconda3-4.3.0-Linux-x86_64.sh && | |
bash Anaconda3-4.3.0-Linux-x86_64.sh -b && | |
rm Anaconda3-4.3.0-Linux-x86_64.sh && | |
pip install -U pip && | |
wget "https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb" && | |
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb && | |
rm cuda-repo-ubuntu1604-8-0-local_8.0.44-1_amd64-deb && | |
sudo apt-get update && | |
sudo apt-get install -y cuda && | |
sudo dpkg -i libcudnn5_5.1.10-1+cuda8.0_amd64.deb && | |
sudo dpkg -i libcudnn5-dev_5.1.10-1+cuda8.0_amd64.deb && | |
echo "export CUDA_HOME=/usr/local/cuda" >> ~/.profile && | |
echo "export CUDA_ROOT=/usr/local/cuda" >> ~/.profile && | |
echo "export PATH=\$PATH:\$CUDA_ROOT/bin" >> ~/.profile && | |
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$CUDA_ROOT/lib64" >> ~/.profile && | |
source ~/.profile && | |
pip install tensorflow-gpu && | |
popd && | |
echo "TF Installation finished." | |
# Part 2: Installing and setting up Jupyter Notebook as a daemon | |
sudo apt-get install -y supervisor && | |
echo "[program:jupyter]" >> /etc/init.d/supervisor/jupyter.conf && | |
echo "user=ubuntu" >> /etc/init.d/supervisor/jupyter.conf && | |
echo "/home/ubuntu/anaconda3/bin/jupyter notebook --ip=0.0.0.0" >> /etc/init.d/supervisor/jupyter.conf && | |
echo "directory=/home/ubuntu/notebooks" >> /etc/init.d/supervisor/jupyter.conf && | |
mkdir -p ~/notebooks && | |
sudo systemctl enable supervisor && | |
sudo systemctl start supervisor && | |
echo "Jupyter is supervised and running in background on port 8888" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment