Oct 10, 2014

Deep Learning: Caffe installation ubuntu 12.04

This is a concise, concrete, and step-wise instruction for installing caffe in ubuntu 12.04 (guided by the instructions given the caffe authors).

Followings are the prerequisite libraries. Carefully install it all.
  • atlas:
    • sudo apt-get install libatlas-base-dev
    • installs into "/usr/include/atlast"
  • boost:
    • sudo apt-get install libboost-all-dev
    • installs into  "/usr/include/boost"
  • OpenCV:
    • sudo apt-get install libopencv-dev
  •  hd5:
    • sudo apt-get install libhdf5-serial-dev
    • install into "/usr/lib/"
  • Addtionally, if python pip is not installed install it using aptitude.

  • google-log:
    • wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
    • cd glog-0.3.3
    • ./configure
    • make
    • sudo make install

  • gflags:
    • wget https://github.com/schuhschuh/gflags/archive/master.zip
    • cd gflags-master/
    • mkdir build && cd build
    • export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
    • make
    • sudo make install

  • numpy:
    • aptitude search numpy
    • sudo aptitude install python-numpy
    • install into " /usr/include/numpy"

 All the pre-requisites are installed, now we can proceed to install the caffe.
  • download the caffe
  • go into the caffe-master
  • copy and rename the Makefile.config
  • do the following change into the Makefile.config
    • # CPU-only switch (uncomment to build without GPU support).
      CPU_ONLY := 1
    • # MATLAB directory should contain the mex binary in /bin. MATLAB_DIR := /usr/local
    • PYTHON_INCLUDE := /usr/include/python2.7 \
              /usr/lib/python2.7/dist-packages/numpy/core/include
  • make all
  • make test
  • make runtest
Try out the pre-trained ImageNet model to test the caffe using python in the following reference.

 Expected issues:
  • append the PYTHONPATH into your ~/.bashrc file with. The following two instruction will do it for you.
    • make python
    • make distribute
  • anaconda GLIB issue:
    • Error: ImportError:  `GLIBC_2.15' not found caffe
    • Solution: delete the 'libm.so and libm.so.6' from ~/anaconda/lib/
  • protobuf issue:
    • Error: caffe ImportError: No module named google.protobuf caffe
    • Solution:
      • find the path where the google-protobuf is installed. for example if it install into "/usr/lib/python2.7/dist-packages/" then do the following into your script.
      • import sys
        sys.path.append("/usr/lib/python2.7/dist-packages/")








2 comments:

McExchange said...

Your link
"download the mdb from github" leads to "https://gitorious.org/mdb" and not to git.
I don't know what link to follow on that side. I installed "mdb/katherines-mdb" but it seems to cause problems :(. I cannot compile caffe. Your help would be appreciated.
(I'm using Ubuntu 12.04)

Neta Zmora said...

Hi MCExchange,

I also ran into this MDB installation problem and I've posted the instructions here: http://netaz.blogspot.com/2015/07/installing-caffe-on-ubuntu-1204.html