Caffe on GPU Cluster
FOR ALL SOFTWARE PACKAGE,
YOU CAN GOOGLE IT AND DOWNLOAD FROM CORRESPONDING WEBSITE.
Clone the caffe
git clone https://github.com/BVLC/caffe.git
Before start this tutorial, you should first install python on cpu clusters
Install python
cd python2.7.9
./configure --prefix=/str/users/tangxu/local/ --enable-shared
make
make install
Attention:
All the path /home/YOURNAME/local should be changed to /str/users/tangxu/local/ if you want to install it on the cpu clusters.
All the path /str/users/tangxu/local/ should be changed to /home/YOURNAME/local if you want to install it on the gpu server.
.bashrc file setting
vim .bashrc
export PATH=/str/users/tangxu/local/bin:$PATH
export LD_LIBRARY_PATH=/str/users/tangxu/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/str/users/tangxu/local/lib/pkgconfig:$PKG_CONFIG_PATH
export PATH=/usr/local/cuda-7.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH
PATH=/str/users/tangxu/local/include:/usr/include:/usr/local/include:$C_INCLUDE_PATH
PATH=/str/users/tangxu/local/include:/usr/include:/usr/local/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/opt/intel/lib/intel64:/opt/intel/mkl/lib/intel64:$LD_LIBRARY_PATH
export PYTHONPATH=/str/users/tangxu/local/lib/python2.7/site-packages/
Install openblas
download openblas
make FC=gfortran NO_AFFINITY=1 USE_OPENMP=1 USE_LAPACK=1
make PREFIX=/str/users/tangxu/local/ install
Install all depend
Install cmake
download cmake
./bootstrap --prefix=/str/users/tangxu/local
make
make install
Install Protobuf
download protobuf
tar zxvf protobuf.tar.gz
cd protobuf
./configure --prefix=/str/users/tangxu/local
make
make install
Install snappy
download snappy
tar zxvf snappy.tar.gz
cd snappyma
./configure --prefix=/str/users/tangxu/local
make
make install
Install leveldb
download leveldb
tar zxvf leveldb.tar.gz
cd leveldb
make
cp -av libleveldb.* /str/users/tangxu/local/lib/
cp -av include/leveldb /str/users/tangxu/local/include/
Install OpenCV
download opencv
tar zxvf opencv.tar.gz
cd opencv
mkdir release && cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/str/users/tangxu/local -D CUDA_GENERATION=Kepler ..
make
make install
Install Boost
download boost
./bootstrap.sh --prefix=/str/users/tangxu/local
./b2 -j 32
./b2 install
Install google-glog [!!!NOT EASY, CONFLICT WITH THE GFLAGS INSTALLED IN /USR/LOCAL BY ROOT]
download glog
tar zxvf glog.tar.gz
cd glog
./configure --prefix=/str/users/tangxu/local
make -j
make install
Install gflags
download gflags
cd gflags
mkdir build && cd build
CXXFLAGS="-fPIC" cmake -D CMAKE_INSTALL_PREFIX=/str/users/tangxu/local ..
make -j
make install
Install lmdb
download lmdb
cd mdb/libraries/liblmdb
make
make prefix=/str/users/tangxu/local install
# man was not found, it does not matter [you should add the file local/man/man1]
Install hdf5
download hdf5
tar zxvf hdf5.tar.gz
cd hdf5
./configure --prefix=/str/users/tangxu/local
make
make check # run test suite.
make install
make check-install # verify installation.
Install cuDNN
download cuDNN
*copy the cudnn lib and head to ~/local/lib and ~/local/include
*or you can download the cudnn library from website and copy
cp /path/to/cudnn/* /str/users/tangxu/local/lib
cp /path/to/cudnn/* /str/users/tangxu/local/include
Add the path int ~/.bashrc
vim ~/.bashrc
============[.bashrc]
// for gpu
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
// for OpenBLAS
export LD_LIBRARY_PATH=/data1/NLPRMNT/xxxxxxxxxx/local/OpenBLAS/lib:$LD_LIBRARY_PATH
#for ~/local
export LD_LIBRARY_PATH=/data1/NLPRMNT/xxxxxxxxxx/local/lib:$LD_LIBRARY_PATH
export PATH=/data1/NLPRMNT/xxxxxxxxxx/local/bin:$PATH
// for openMP
export OMP_NUM_THREADS=20
============
source ~/.bashrc
Compile caffe
*Edit the Makefile.config
cp Makefile.config.example Makefile.config
vim Makefile.config
============[Makefile.config]
USE_CUDNN := 1
CUDA_DIR := /usr/local/cuda
BLAS := open
BLAS_INCLUDE := /data1/NLPRMNT/xxxxxxxxxx/local/OpenBLAS/include
BLAS_LIB := /data1/NLPRMNT/xxxxxxxxxx/local/OpenBLAS/lib
INCLUDE_DIRS := /data1/NLPRMNT/xxxxxxxxxx/local/include
LIBRARY_DIRS := /data1/NLPRMNT/xxxxxxxxxx/local/lib
#commit the python/matlab part
============
*make, the first two lines were run on login node
make all -j8
make test -j8
make runtest -j8