sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y opencl-headers build-essential protobuf-compiler \
libprotoc-dev libboost-all-dev libleveldb-dev hdf5-tools libhdf5-serial-dev \
libopencv-dev libopenblas-dev liblapack-dev libsnappy-dev libsnappy1 \
cmake libstdc++6-4.8-dbg libgoogle-glog0 libgoogle-glog-dev \
libgflags-dev liblmdb-dev git python-pip gfortran
# kernel source dependecies for cuda drivers and cuda toolkit
sudo apt-get install -y linux-image-extra-`uname -r` linux-headers-`uname -r` linux-image-`uname -r`
# download & install CUDA 7.0 Ubuntu repository from NVidia's website
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/cuda-repo-ubuntu1404_7.0-28_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1404_7.0-28_amd64.deb
# Update Ubuntu's package manager
sudo apt-get update && sudo apt-get upgrade
# Install package "cuda-7-0". It includes CUDA drivers, CUDA toolkit and other utilities
sudo apt-get install cuda-7-0
# check whether nvidia drivers are installed correctly. It would show details about your GPU
nvidia-smi
# Configure configure ldconfig so that CUDA binaries are visible
sudo sh -c "sudo echo '/usr/local/cuda/lib64' > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig
To obtain cuDNN you have to register at NVidia's Accelerated Computing Developer Program After registration, you can download cuDNN from this link We have used cuDNN v4.
tar -xvf cudnn-7.0-linux-x64-v4.0-prod.tgz
# -P flag is important because it retains the symlinks
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
# Run ldconfig again
sudo ldconfig
To install OpenCV use this automation script by Jay Rambhia. We will install OpenCV 2.4.10
# Open this script and define these 2 variables at the top of script.
# version=2.4.10 and
# downloadfile=opencv-2.4.10.zip
# At line 45, where `cmake` command is specified, add an extra flag which specifies GPU architecture:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CUDA_GENERATION=Kepler
# So the full `cmake` command would be:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler \
-D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
Note: Don't install OpenCV 2.4.9. It has a bug due to which it gives compile error while building OpenCV CUDA modules.
# Install py-faster-rcnn dependencies
sudo pip install Cython
sudo pip install easydict
git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git
cd py-faster-rcnn/lib
# IMPORTANT: Since we are using NVidia Kepler 520 GPU, which has compute capability of 3.0
# change line 135 in py-faster-rcnn/lib/setup.py
# from '-arch=sm_35' =====> '-arch=sm_30'
# compile py-faster-rcnn Cython modules
make
# Now we will compile Caffe
cd ../caffe-faster-rcnn
for req in $(cat requirements.txt); do sudo pip install -U $req; done
# prepare Makefile.config
cp Makefile.config.example Makefile.config
# make following changes
# Uncomment following lines
USE_CUDNN := 1
WITH_PYTHON_LAYER := 1
USE_PKG_CONFIG := 1
# Change BLAS and PYTHON_INCLUDE to following values
BLAS := open
PYTHON_INCLUDE := /usr/include/python2.7 \
/usr/lib/python2.7/dist-packages/numpy/core/include \
/usr/local/lib/python2.7/dist-packages/numpy/core/include/
# compile Caffe modules
make -j8 all
# Since this is a fork of original caffe. There is a small bug due to which
# compilation of test modules fails with following error message:
# test_smooth_L1_loss_layer.cpp:11:35: fatal error: caffe/vision_layers.hpp: No such file or directory
# Solution: https://github.com/rbgirshick/py-faster-rcnn/issues/155
# remove line 11 in src/caffe/test/test_smooth_L1_loss_layer.cpp where vision_layers.hpp is included
make -j8 test
# run tests to ensure all the tests are passed
make runtest
# build pycaffe
make pycaffe
Now that we have installed Caffe and py-faster-rcnn, we can follow demo and training instructions from py-faster-rcnn's Github repo
Thanks, this script helped me!