-
Notifications
You must be signed in to change notification settings - Fork 13
Building: Caffe Support
SAF has been tested with the following versions of Caffe:
# Checkout/download the appropriate version of Caffe
cp ./Makefile.config.example ./Makefile.config
# Enable OPENCV 3 support in Makefile.config
Note that if the above doesn't work out of the box with your hdf5,
edit your Makefile.config
and Makefile
.
# Makefile.config
-INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
+INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
# Makefile
-LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial
Intel Caffe installation process will look for a globally-installed version of MKL-DNN on the system. If it finds one, it will use that. If not, it will automatically download and build a local copy. The following instructions are for this latter case.
The symptom is that SAF will fail to link, saying that is cannot find
MKL-DNN. The underlying issues is that the Intel Caffe build system links against
its local copy of libmkldnn.so using a relative path instead of an absolute path.
You can verify that this is indeed the issue by running ldd
on libcaffe.so
.
Note: This issue does not apply to BVLC Caffe or any version of Caffe that does not use MKL-DNN.
Solution:
-
Build Intel Caffe (https://github.com/intel/caffe) as usual using the above instructions. This step is important: If you do steps 2-4 before building Caffe for the first time, it will not compile.
-
Remove the generated libraries to force Caffe's build system to relink them
rm /path/to/caffe/build/lib/* rm /path/to/caffe/distribute/lib/*
-
Apply the change below to Makefile.mkldnn
diff --git a/Makefile.mkldnn b/Makefile.mkldnn index ec1a70bc..ed8c8046 100644 --- a/Makefile.mkldnn +++ b/Makefile.mkldnn @@ -1,5 +1,5 @@ CAFFE_ROOTDIR := $(shell pwd) -MKLDNN_ROOTDIR := external/mkldnn +MKLDNN_ROOTDIR := $(CAFFE_ROOTDIR)/external/mkldnn MKLDNN_TMPDIR := $(MKLDNN_ROOTDIR)/tmp MKLDNN_SRCDIR := $(MKLDNN_ROOTDIR)/src MKLDNN_BUILDDIR := $(MKLDNN_ROOTDIR)/build
-
Relink Caffe
make && make distribute
At this point, SAF should successfully link against Intel Caffe. You can
verify that libcaffe.so
is using an absolute path for libmkldnn.so
by
running ldd
.
You must point SAF's build system to Caffe's location.
cmake -DUSE_CAFFE=yes -DCAFFE_HOME=<path to Caffe>/distribute ..