Last active
October 15, 2016 01:59
-
-
Save rummanwaqar/c4cad804508f69b99a1a13897394b916 to your computer and use it in GitHub Desktop.
Install Caffe on EC2
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
git clone https://github.com/NVIDIA/DIGITS.git digits | |
git checkout digits-4.0 | |
cd digits | |
sudo apt-get install graphviz gunicorn | |
for req in $(cat requirements.txt); do sudo pip install $req; done | |
# to run | |
./digits-devserver -p PORT | |
# default port is 5000 |
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
# ssh into the machine | |
ssh -i key.pem ubuntu@<ip> | |
# update the machine | |
sudo apt-get update && sudo apt-get upgrade -y | |
# essentials | |
sudo apt-get install build-essential git htop | |
# download and extract cuda | |
wget http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run | |
chmox +x cuda_7.5.18_linux.run | |
mkdir nvidia_installers | |
./cuda_7.5.18_linux.run -extract=`pwd`/nvidia_installers | |
############################# | |
# installing nvidia drivers # | |
############################# | |
# update kernel to be compatible | |
sudo apt-get install linux-image-extra-virtual | |
# disable nouveau | |
sudo vi /etc/modprobe.d/blacklist-nouveau.conf | |
blacklist nouveau | |
blacklist lbm-nouveau | |
options nouveau modeset=0 | |
alias nouveau off | |
alias lbm-nouveau off | |
# then execute | |
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf | |
sudo update-initramfs -u | |
sudo reboot | |
# after reboot | |
sudo apt-get install linux-source | |
sudo apt-get install linux-headers-`uname -r` | |
# download and install the drivers | |
cd nvidia_drivers | |
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/361.45.11/NVIDIA-Linux-x86_64-361.45.11.run | |
sudo /bin/bash ./NVIDIA-Linux-x86_64-361.45.11.run | |
sudo reboot | |
# test nvidia drivers | |
nvidia-smi | |
########################## | |
# Install Cuda and cuDNN # | |
########################## | |
sudo modprobe nvidia | |
cd nvidia_installers | |
sudo ./cuda-linux64-rel-7.5.18-19867135.run | |
# install the samples in home directory | |
sudo ./cuda-samples-linux-7.5.18-19867135.run | |
# to change sample permissions from root to ubuntu | |
sudo chown -R ubuntu:ubuntu cuda_samples/ | |
# add paths to bashrc | |
vim ~/.bashrc | |
export PATH=$PATH:/usr/local/cuda-7.5/bin | |
export LD_LIBRARY_PATH=:/usr/local/cuda-7.5/lib64 | |
source ~/.bashrc | |
sudo ldconfig | |
# install cuDNN | |
# download cuDNN locally and then use scp | |
scp -i key.pem cudnn-7.5-linux-x64-v5.1.tgz ubuntu@<ip>:~/nvidia_installers | |
tar -zxf cudnn-7.5-linux-x64-v5.1.tgz | |
cd cuda | |
sudo cp lib64/* /usr/local/cuda-7.5/lib64/ | |
sudo cp include/cudnn.h /usr/local/cuda/include/ | |
#################### | |
# Installing Caffe # | |
#################### | |
# install dependencies | |
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libboost-all-dev libhdf5-serial-dev protobuf-compiler gfortran libjpeg62 libfreeimage-dev libatlas-base-dev git python-dev python-pip libgoogle-glog-dev libbz2-dev libxml2-dev libxslt-dev libffi-dev libssl-dev libgflags-dev liblmdb-dev python-yaml python-numpy | |
sudo easy_install pillow | |
# clone caffe | |
# git clone https://github.com/BVLC/caffe.git | |
# git clone https://github.com/NVIDIA/caffe.git | |
# install python requirements | |
cd caffe/python | |
for req in $(cat requirements.txt); do pip install $req; done | |
# build caffe | |
cd ~/caffe | |
cp Makefile.config.example Makefile.config | |
vim Makefile.config | |
# Uncomment the line: USE_CUDNN := 1 | |
# Make sure the CUDA_DIR correctly points to our CUDA installation. | |
make pycaffe -j32 | |
make all -j32 | |
make test -j32 | |
# test caffe | |
./data/mnist/get_mnist.sh | |
./examples/mnist/create_mnist.sh | |
./examples/mnist/train_lenet.sh | |
echo -e "\nexport CAFFE_HOME=/home/ubuntu/caffe" >> ~/.bashrc | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment