Compiling Caffe
Versions and Forks
- The original Caffe is from Berkeley AI Research[1]. This uses GPUs (CUDA) with the limitation that only a single GPU device may be used at a time.
- NVIDIA forked Caffe, adding some features, notably the ability to use more than one GPU device[2]
- Caffe2 forked by Facebook[3][4]
Order of Operations
Prerequisite
- cmake >= 3.8
- C++ 11 i.e. gcc > 4.8
Compilation Order
Some of these may be provided by system.
- hdf5 1.8.x
- gflags
- glog
- snappy
- leveldb
- lmdb
- Python 2.7.13
- numpy
- scipy
- etc
- scons - works only with Python 2.x
- Boost
- caffe
- NVML - /cm/shared/apps/cuda60/tdk/331.62/nvml
Configure
There are two ways to do it:
- the "official" way is to manually edit the Makefile.config at the top of the source tree.
- the other way is to use the unofficial Cmake.
I find Cmake a little easier to deal with.
Using ccmake
To use ccmake, a separate build directory must be created, and the build run from there:
[juser@proteusi01 caffe-1.0]$ mkdir build
[juser@proteusi01 caffe-1.0]$ cd build
[juser@proteusi01 caffe-1.0]$ ccmake ..
Then, hit "c" to start the configure process; it will take a minute or two. Then, once a list of options/cmake variables appear, hit "t" to toggle on the advanced options. Use the cursor keys to navigate to any variable you want to modify; hit "Enter" to start editing, and hit "Return" once done. Repeat the editing process for all variables you need to modify.
With some variables, once a modification is made, hitting "c" to configure will pull in more variables, e.g. for using Intel MKL the variables setting various MKL library locations will come up. Keep hitting "c" until the option "g" to generate appears. It should take only one or two iterations. Once you hit "g", the makefile is generated and the cmake configurator will exit.
Then, follow the rest of the caffe build instructions[5]
make
make pycaffe
make runtest
make install
NVCaffe
- NVML location - /cm/shared/apps/cuda60/tdk/331.62/nvml
References
[1] Berkeley AI Research - Caffe official website
[2] NVIDIA caffe GitHub repository
[4] NVIDIA Dev Blog - Caffe2: Portable High-Performance Deep Learning Framework from Facebook