1. Using system python
#!/bin/sh
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install gfortran
cd ~/src
git clone https://github.com/BVLC/caffe.git
cd caffe
cp Makefile.config.example Makefile.config
# Adjust Makefile.config
# set CPU_ONLY
# set MATLAB_DIR
make all
make test
make runtest
cd caffe
sudo pip install -r requirements.txt
make pycaffe
But errors may occur while piping. Anaconda is a good substitution.
Or, you can try pip install package in requirements.txt one by one.
2. Using anaconda
#!/bin/sh
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
cd ~/
git clone https://github.com/BVLC/caffe.git
cd ~/Downloads
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
chmod +x Anaconda2-4.2.0-Linux-x86_64.sh
./Anaconda2-4.2.0-Linux-x86_64.sh
# edit Makefile.conf
# set CPU_ONLY
# set USE_OPENCV
# set OPENCV_VERSION
# set ANACONDA_HOME (check path carefully!)
# set PYTHON_INCLUDE
# set PYTHON_LIB
# set WITH_PYTHON_LAYER
cd ~/caffe
make all
make test
make runtest
make pycaffe
# using anaconda python
source ~/.bashrc
export PYTHONPATH=$PYTHONPATH:~/caffe/python
python -c 'import caffe'
If no error occurs, done.