Compiling Caffe C++ Classification Example

Jack Simpson picture Jack Simpson · Aug 26, 2015 · Viewed 7k times · Source

I recently modified the Caffe C++ classification example file and I am trying to recompile it. However, I'm having trouble linking a simple g++ compilation to the .hpp files in the include directory. I know this is a basic question but I can't seem to work it out - can someone help me work out how to compile this program? The compilation looks like this now:

g++ -I /home/jack/caffe/include classification.cpp -o classify

But I'm getting this error:

In file included from /home/jack/caffe/include/caffe/common.hpp:19:0,
    from /home/jack/caffe/include/caffe/blob.hpp:8,
    from /home/jack/caffe/include/caffe/caffe.hpp:7,
    from classification.cpp:1:
/home/jack/caffe/include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
 #include <cublas_v2.h>

I'm running this on a machine without Nvidia GPUs so when I looked at the device_alternate.hpp file I realised this is calling a lot of cuda-related .hpp files as well which don't exist.

Answer

Shai picture Shai · Aug 26, 2015

Usually, in order to help the compiler locate header files you need to add -I /path/to/include/folder option to the compilation line:

~$ g++ -I /path/to/caffe/include myfile.cpp