Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install TensorFlow and Anaconda on an Amazon EC2 P2
# 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
# 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 &&
bash -b &&
rm &&
pip install -U pip &&
wget "" &&
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=" >> /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