π 2017-Feb-22 ⬩ βοΈ Ashwin Nanjappa ⬩ π·οΈ caffe, matcaffe, matlab ⬩ π Archive
Building Caffe from source is easy. There are two options provided: using a Makefile or using CMake.
Download or clone the source code of Caffe from here.
Not surprisingly, you will need a GPU, a graphics driver that can work with that GPU and an installation of CUDA.
Other than that, you will need to install these packages:
$ sudo apt install libboost-all-dev libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev
$ sudo apt install libatlas-base-dev
$ sudo apt install libopenblas-dev
$ sudo apt install libboost-python-dev python-skimage python-protobuf
The dependency target "pycaffe" of target "pytest" does not exist.
ImportError: No module named skimage.io
ImportError: No module named google.protobuf.internal
Just follow the usual steps for CMake:
$ mkdir build
$ cd build
$ cmake ..
$ make
To build and run the 2000+ unittests, which can take quite a while to finish:
$ make runtest
Finally to build the Python interface to Caffe:
$ make pycaffe
$ make install
By default, the install directory will be a subdirectory inside the build
directory. Add this build/install/python
path to PYTHONPATH
environment variable before you import caffe in Python.
On one system, I found that using Makefile was easier, since CMake was erroneously complaining about -lpthreads
(which is a Clang library, not a GCC library). Copy the Makefile config file, open it in an editor and check whether all the paths are set correctly:
$ cp Makefile.config.example Makefile.config
$ vim Makefile.config
$ make
Building support for MATLAB to use Caffe takes a few more steps:
In Makefile.config, set the MATLAB_DIR
to the path that contains bin/mex
. On my computer, this was the path /usr/local/MATLAB/R2014a
.
Compiling the MATLAB wrapper gave an error about C++11 on my Ubuntu 14.04 due to the older GCC compilers. So, I had to add -std=c++11
to the CXXFLAGS
variable in Makefile
as shown here.
Finally, compiling MatCaffe is easy:
$ make all matcaffe