1.2 Detailed description

In this section we will explain what the script in Chapter 1.1 does. Note if you run these commands line-by-line, you may need to use sudo for some commands.

Install development packages

apt-get --yes --force-yes install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
apt-get --yes --force-yes install --no-install-recommends libboost-all-dev
apt-get --yes --force-yes install python-dev
apt-get --yes --force-yes install libgflags-dev libgoogle-glog-dev liblmdb-dev

Install CUDA

Skipped.

Install OpenBLAS

Installation for OpenBLAS may also be done via apt-get, but if we compile it from source, OpenBLAS will be fully optimized to our machine. We put the source code in ~/src/, and install it in /opt/openBLAS.

  • Get compilation tools
    apt-get install git python-dev gfortran
    
  • Change directory to ~/src, and fetch the source codes.
    mkdir ~/src
    cd ~/src
    git clone https://github.com/xianyi/OpenBLAS
    
  • Compile and install with our settings. Use gfortran as our fortran compiler, and set the installation target to /opt/openblas
    cd OpenBLAS
    make FC=gfortran
    make PREFIX=/opt/openblas install
    
  • Let system know where OpenBLAS library resides
    sh -c "echo '/opt/openblas/lib/' > /etc/ld.so.conf.d/openblas.conf"
    ldconfig
    

Install Caffe

Once previous works have been done, we are ready to install Caffe.

  • We also put the source codes in ~/src
    cd ~/src
    git clone https://github.com/BVLC/caffe
    
  • Modify the configuration. The 1st sed choose openBLAS (rather than ATLAS) to use. The 2nd and 3rd sed set the path to library. The 4th sed turns CPU_ONLY on, since we didn't install CUDA for GPU mode. The 5th and 6th sed may be omitted, they are for Ubuntu versions greater than or equal to 15.04.
    cd caffe
    cp Makefile.config.example Makefile.config
    sed -i "s/\(BLAS *:= *\).*/\1open/" Makefile.config
    sed -i "s/\(# BLAS_INCLUDE *:= *\).*/BLAS_INCLUDE := \/opt\/openblas\/include/" Makefile.config
    sed -i "s/\(# BLAS_LIB *:= *\).*/BLAS_LIB := \/opt\/openblas\/lib/" Makefile.config
    sed -i "s/\(# CPU_ONLY.*\).*/CPU_ONLY := 1/" Makefile.config
    sed -i "s/\(INCLUDE_DIRS.*\).*/\1 \/usr\/include\/hdf5\/serial\//" Makefile.config # for ubuntu 15.04
    sed -i "s/\(LIBRARY_DIRS.*\).*/\1 \/usr\/lib\/x86_64-linux-gnu\/hdf5\/serial\/ := 1/" Makefile.config # for ubuntu 15.04
    
  • Compile in parallel with 8 threads.
    make all -j8
    
  • Test the installation
    make test
    make runtest
    

results matching ""

    No results matching ""