New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add caffe using CMake #4

Open
gaopeng-eugene opened this Issue Aug 20, 2016 · 20 comments

Comments

Projects
None yet
9 participants
@gaopeng-eugene

gaopeng-eugene commented Aug 20, 2016

My Caffe in installed on local file. Can you share a CMakeLists file to demonstrate how to link Caffe with your project,

Thank you.

@metropt

This comment has been minimized.

Show comment
Hide comment
@metropt

metropt Aug 23, 2016

same problem here :s

metropt commented Aug 23, 2016

same problem here :s

@davheld

This comment has been minimized.

Show comment
Hide comment
@davheld

davheld Aug 30, 2016

Owner

Try adding:

set(Caffe_DIR )

in your CMakeLists.txt, replacing "" with your actual path. The line should be placed above:

find_package(Caffe REQUIRED)

Owner

davheld commented Aug 30, 2016

Try adding:

set(Caffe_DIR )

in your CMakeLists.txt, replacing "" with your actual path. The line should be placed above:

find_package(Caffe REQUIRED)

@davheld

This comment has been minimized.

Show comment
Hide comment
@davheld

davheld Sep 6, 2016

Owner

Not sure - are you using the latest version of Caffe? Did you install
Caffe and compile using the CMake build instructions:
http://caffe.berkeleyvision.org/installation.html ?

On Tue, Sep 6, 2016 at 6:04 AM, Jiangfeng-Xiong notifications@github.com
wrote:

set(Caffe_DIR ) does help,but I come cross another problem
""" "No rule to make target /home/john/caffe-master/lib/libproto.a',
needed bysave_videos_vot'. Stop."""

how can I deal with this?

Thank you.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#4 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEHoHBuK5qtcr5HJDpR9_l4JQ16sj2Nvks5qnWTHgaJpZM4JpCjy
.

Owner

davheld commented Sep 6, 2016

Not sure - are you using the latest version of Caffe? Did you install
Caffe and compile using the CMake build instructions:
http://caffe.berkeleyvision.org/installation.html ?

On Tue, Sep 6, 2016 at 6:04 AM, Jiangfeng-Xiong notifications@github.com
wrote:

set(Caffe_DIR ) does help,but I come cross another problem
""" "No rule to make target /home/john/caffe-master/lib/libproto.a',
needed bysave_videos_vot'. Stop."""

how can I deal with this?

Thank you.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#4 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AEHoHBuK5qtcr5HJDpR9_l4JQ16sj2Nvks5qnWTHgaJpZM4JpCjy
.

@metropt

This comment has been minimized.

Show comment
Hide comment
@metropt

metropt Sep 21, 2016

almost done... :s

ze@ze-FI:~/Development/GOTURN/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- No build type selected, default to Release
-- Boost version: 1.54.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   regex
-- Found TinyXML: /usr/lib/x86_64-linux-gnu/libtinyxml.so  
Open CV version is 2.4.8
-- Found Caffe: /home/ze/Development/caffe/build/lib/  
Caffe_DIR is /home/ze/Development/caffe/
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ze/Development/GOTURN/build
ze@ze-FI:~/Development/GOTURN/build$ make
Scanning dependencies of target GOTURN
[  3%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/bounding_box.cpp.o
[  7%] Building CXX object CMakeFiles/GOTURN.dir/src/train/example_generator.cpp.o
[ 11%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/helper.cpp.o
[ 15%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/high_res_timer.cpp.o
[ 19%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/image_proc.cpp.o
[ 23%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_alov.cpp.o
[ 26%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_imagenet_det.cpp.o
[ 30%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_vot.cpp.o
[ 34%] Building CXX object CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o
In file included from /home/ze/Development/GOTURN/src/network/regressor.cpp:1:0:
/home/ze/Development/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory
 #include <caffe/caffe.hpp>
                           ^
compilation terminated.
make[2]: *** [CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o] Error 1
make[1]: *** [CMakeFiles/GOTURN.dir/all] Error 2
make: *** [all] Error 2
ze@ze-FI:~/Development/GOTURN/build$

metropt commented Sep 21, 2016

almost done... :s

ze@ze-FI:~/Development/GOTURN/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- No build type selected, default to Release
-- Boost version: 1.54.0
-- Found the following Boost libraries:
--   system
--   filesystem
--   regex
-- Found TinyXML: /usr/lib/x86_64-linux-gnu/libtinyxml.so  
Open CV version is 2.4.8
-- Found Caffe: /home/ze/Development/caffe/build/lib/  
Caffe_DIR is /home/ze/Development/caffe/
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ze/Development/GOTURN/build
ze@ze-FI:~/Development/GOTURN/build$ make
Scanning dependencies of target GOTURN
[  3%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/bounding_box.cpp.o
[  7%] Building CXX object CMakeFiles/GOTURN.dir/src/train/example_generator.cpp.o
[ 11%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/helper.cpp.o
[ 15%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/high_res_timer.cpp.o
[ 19%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/image_proc.cpp.o
[ 23%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_alov.cpp.o
[ 26%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_imagenet_det.cpp.o
[ 30%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_vot.cpp.o
[ 34%] Building CXX object CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o
In file included from /home/ze/Development/GOTURN/src/network/regressor.cpp:1:0:
/home/ze/Development/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory
 #include <caffe/caffe.hpp>
                           ^
compilation terminated.
make[2]: *** [CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o] Error 1
make[1]: *** [CMakeFiles/GOTURN.dir/all] Error 2
make: *** [all] Error 2
ze@ze-FI:~/Development/GOTURN/build$
@davheld

This comment has been minimized.

Show comment
Hide comment
@davheld

davheld Sep 21, 2016

Owner

Are you using the latest version of Caffe? This might be a problem if you are using an old version.

Owner

davheld commented Sep 21, 2016

Are you using the latest version of Caffe? This might be a problem if you are using an old version.

@metropt

This comment has been minimized.

Show comment
Hide comment
@metropt

metropt Sep 28, 2016

delete everthing, clone caffe, build it and now I got the following error:

ze@ze-FI:~/Development/GOTURN/build$ make
Scanning dependencies of target GOTURN
[  3%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/bounding_box.cpp.o
[  7%] Building CXX object CMakeFiles/GOTURN.dir/src/train/example_generator.cpp.o
[ 11%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/helper.cpp.o
[ 15%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/high_res_timer.cpp.o
[ 19%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/image_proc.cpp.o
[ 23%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_alov.cpp.o
[ 26%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_imagenet_det.cpp.o
[ 30%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_vot.cpp.o
[ 34%] Building CXX object CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o
In file included from /home/ze/Development/caffe/build/install/include/caffe/common.hpp:19:0,
                 from /home/ze/Development/caffe/build/install/include/caffe/blob.hpp:8,
                 from /home/ze/Development/caffe/build/install/include/caffe/caffe.hpp:7,
                 from /home/ze/Development/GOTURN/src/network/regressor.h:4,
                 from /home/ze/Development/GOTURN/src/network/regressor.cpp:1:
/home/ze/Development/caffe/build/install/include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
 #include <cublas_v2.h>
                       ^
compilation terminated.
make[2]: *** [CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o] Error 1
make[1]: *** [CMakeFiles/GOTURN.dir/all] Error 2
make: *** [all] Error 2
ze@ze-FI:~/Development/GOTURN/build$ 

Any idea?

metropt commented Sep 28, 2016

delete everthing, clone caffe, build it and now I got the following error:

ze@ze-FI:~/Development/GOTURN/build$ make
Scanning dependencies of target GOTURN
[  3%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/bounding_box.cpp.o
[  7%] Building CXX object CMakeFiles/GOTURN.dir/src/train/example_generator.cpp.o
[ 11%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/helper.cpp.o
[ 15%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/high_res_timer.cpp.o
[ 19%] Building CXX object CMakeFiles/GOTURN.dir/src/helper/image_proc.cpp.o
[ 23%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_alov.cpp.o
[ 26%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_imagenet_det.cpp.o
[ 30%] Building CXX object CMakeFiles/GOTURN.dir/src/loader/loader_vot.cpp.o
[ 34%] Building CXX object CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o
In file included from /home/ze/Development/caffe/build/install/include/caffe/common.hpp:19:0,
                 from /home/ze/Development/caffe/build/install/include/caffe/blob.hpp:8,
                 from /home/ze/Development/caffe/build/install/include/caffe/caffe.hpp:7,
                 from /home/ze/Development/GOTURN/src/network/regressor.h:4,
                 from /home/ze/Development/GOTURN/src/network/regressor.cpp:1:
/home/ze/Development/caffe/build/install/include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: No such file or directory
 #include <cublas_v2.h>
                       ^
compilation terminated.
make[2]: *** [CMakeFiles/GOTURN.dir/src/network/regressor.cpp.o] Error 1
make[1]: *** [CMakeFiles/GOTURN.dir/all] Error 2
make: *** [all] Error 2
ze@ze-FI:~/Development/GOTURN/build$ 

Any idea?

@ksaluja15

This comment has been minimized.

Show comment
Hide comment
@ksaluja15

ksaluja15 Sep 29, 2016

Contributor

#9

Contributor

ksaluja15 commented Sep 29, 2016

#9

@OuYag

This comment has been minimized.

Show comment
Hide comment
@OuYag

OuYag Oct 17, 2016

I have the same problems as you @metropt ,how do you solver it?

OuYag commented Oct 17, 2016

I have the same problems as you @metropt ,how do you solver it?

@metropt

This comment has been minimized.

Show comment
Hide comment
@metropt

metropt Oct 17, 2016

@OuYag take a look at #14

metropt commented Oct 17, 2016

@OuYag take a look at #14

@OuYag

This comment has been minimized.

Show comment
Hide comment
@OuYag

OuYag Oct 18, 2016

@metropt my trouble is "/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory",and I have build the latest version of Caffe, you means #14 only can build caffe with cpu model?

OuYag commented Oct 18, 2016

@metropt my trouble is "/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory",and I have build the latest version of Caffe, you means #14 only can build caffe with cpu model?

@metropt

This comment has been minimized.

Show comment
Hide comment
@metropt

metropt Oct 18, 2016

@OuYag check please my FindCaffe.cmake

# Caffe package
unset(Caffe_FOUND)

###Set the variable Caffe_DIR as the root of your caffe directory
set(Caffe_DIR ~/Development/caffe/distribute)


find_path(Caffe_INCLUDE_DIRS NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp caffe/vision_layers.hpp
  HINTS
  ${Caffe_DIR}/include)



find_library(Caffe_LIBRARIES NAMES caffe
  HINTS
  ${Caffe_DIR}/lib)

message("lib_dirs:${Caffe_LIBRARIES}")

if(Caffe_LIBRARIES AND Caffe_INCLUDE_DIRS)
    set(Caffe_FOUND 1)
endif()

metropt commented Oct 18, 2016

@OuYag check please my FindCaffe.cmake

# Caffe package
unset(Caffe_FOUND)

###Set the variable Caffe_DIR as the root of your caffe directory
set(Caffe_DIR ~/Development/caffe/distribute)


find_path(Caffe_INCLUDE_DIRS NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp caffe/vision_layers.hpp
  HINTS
  ${Caffe_DIR}/include)



find_library(Caffe_LIBRARIES NAMES caffe
  HINTS
  ${Caffe_DIR}/lib)

message("lib_dirs:${Caffe_LIBRARIES}")

if(Caffe_LIBRARIES AND Caffe_INCLUDE_DIRS)
    set(Caffe_FOUND 1)
endif()
@vj-1988

This comment has been minimized.

Show comment
Hide comment
@vj-1988

vj-1988 Oct 18, 2016

With respect to #include <cublas_v2.h> error, as a crude fix I explicitly provided the path of cublas_v2.h and few other headers after that and I am able to compile the project successfully.

vj-1988 commented Oct 18, 2016

With respect to #include <cublas_v2.h> error, as a crude fix I explicitly provided the path of cublas_v2.h and few other headers after that and I am able to compile the project successfully.

@davheld

This comment has been minimized.

Show comment
Hide comment
@davheld

davheld Oct 19, 2016

Owner

@vj-1988 good find! Feel free to submit a pull request if you think that this would be helpful to others (you can use path names like ).

Owner

davheld commented Oct 19, 2016

@vj-1988 good find! Feel free to submit a pull request if you think that this would be helpful to others (you can use path names like ).

@OuYag

This comment has been minimized.

Show comment
Hide comment
@OuYag

OuYag Oct 19, 2016

thanks, @metropt,I have adds Caffe_DIR to FindCmake.cmake,but no useful,and then I solver it by export PATH=caffe/include and export CPLUS_INCLUDE_PATH=caffe/build/include in ~/.bashrc to find head file,complie sucessfully.

OuYag commented Oct 19, 2016

thanks, @metropt,I have adds Caffe_DIR to FindCmake.cmake,but no useful,and then I solver it by export PATH=caffe/include and export CPLUS_INCLUDE_PATH=caffe/build/include in ~/.bashrc to find head file,complie sucessfully.

@ml-inory

This comment has been minimized.

Show comment
Hide comment
@ml-inory

ml-inory Oct 19, 2016

@vj-1988 I got the same #include error,could you please tell me how to solve it specifically?

ml-inory commented Oct 19, 2016

@vj-1988 I got the same #include error,could you please tell me how to solve it specifically?

@vj-1988

This comment has been minimized.

Show comment
Hide comment
@vj-1988

vj-1988 Oct 19, 2016

Hi all. I don't have the complete list of changes I made, but as a starting step I made this change to device_alternate.hpp file in the caffe location.

#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cublas_v2.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cuda.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cuda_runtime.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/curand.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/driver_types.h>

vj-1988 commented Oct 19, 2016

Hi all. I don't have the complete list of changes I made, but as a starting step I made this change to device_alternate.hpp file in the caffe location.

#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cublas_v2.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cuda.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/cuda_runtime.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/curand.h>
#include </usr/local/cuda-7.5/targets/x86_64-linux/include/driver_types.h>

@fromlimbo

This comment has been minimized.

Show comment
Hide comment
@fromlimbo

fromlimbo Jan 7, 2017

@metropt is right. The FindCaffe.cmake file made some mistakes. Maybe our caffe is not the same version. The Caffe_DIR is ~/xx/caffe/distribute.(If your distribute file is empty,you shoud do
"make distribute" in your caffe root).
And change "find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/build/lib)" into
find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/lib),hope you guys get it done.

fromlimbo commented Jan 7, 2017

@metropt is right. The FindCaffe.cmake file made some mistakes. Maybe our caffe is not the same version. The Caffe_DIR is ~/xx/caffe/distribute.(If your distribute file is empty,you shoud do
"make distribute" in your caffe root).
And change "find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/build/lib)" into
find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/lib),hope you guys get it done.

@JohnKeating24

This comment has been minimized.

Show comment
Hide comment
@JohnKeating24

JohnKeating24 May 3, 2017

Hi, @OuYag, i meet the same error with you,"/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory",and i did according to your method,but failed. And I don't think the path is correct.Maybe you didn't give the full path.Could you explain in detail? thanks

JohnKeating24 commented May 3, 2017

Hi, @OuYag, i meet the same error with you,"/GOTURN/src/network/regressor.h:4:27: fatal error: caffe/caffe.hpp: No such file or directory",and i did according to your method,but failed. And I don't think the path is correct.Maybe you didn't give the full path.Could you explain in detail? thanks

@OuYag

This comment has been minimized.

Show comment
Hide comment
@OuYag

OuYag May 4, 2017

@JohnKeating24 its my FindCaffe.cmake file:

Caffe package

unset(Caffe_FOUND)

###Set the variable Caffe_DIR as the root of your caffe directory
set(Caffe_DIR /home/ouya/GOTURN/caffe/build)

find_path(Caffe_INCLUDE_DIRS NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp caffe/vision_layers.hpp
HINTS
${Caffe_DIR}/include)

find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/lib)

message("lib_dirs:${Caffe_LIBRARIES}")

if(Caffe_LIBRARIES AND Caffe_INCLUDE_DIRS)
set(Caffe_FOUND 1)
endif()


then,i also add the some path in ~/.bashrc,the info as:

##GOTURN###
export CPLUS_INCLUDE_PATH=/home/ouya/GOTURN/caffe/build/include:$CPLUS_INCLUDE_PATH
export PATH=/home/ouya/GOTURN/caffe/include:$PATH

please attention that my caffe directory is in GOTURN,and remember do "source ~/.bashrc" when you change the .bashrc,i hope it can help you.

OuYag commented May 4, 2017

@JohnKeating24 its my FindCaffe.cmake file:

Caffe package

unset(Caffe_FOUND)

###Set the variable Caffe_DIR as the root of your caffe directory
set(Caffe_DIR /home/ouya/GOTURN/caffe/build)

find_path(Caffe_INCLUDE_DIRS NAMES caffe/caffe.hpp caffe/common.hpp caffe/net.hpp caffe/proto/caffe.pb.h caffe/util/io.hpp caffe/vision_layers.hpp
HINTS
${Caffe_DIR}/include)

find_library(Caffe_LIBRARIES NAMES caffe
HINTS
${Caffe_DIR}/lib)

message("lib_dirs:${Caffe_LIBRARIES}")

if(Caffe_LIBRARIES AND Caffe_INCLUDE_DIRS)
set(Caffe_FOUND 1)
endif()


then,i also add the some path in ~/.bashrc,the info as:

##GOTURN###
export CPLUS_INCLUDE_PATH=/home/ouya/GOTURN/caffe/build/include:$CPLUS_INCLUDE_PATH
export PATH=/home/ouya/GOTURN/caffe/include:$PATH

please attention that my caffe directory is in GOTURN,and remember do "source ~/.bashrc" when you change the .bashrc,i hope it can help you.

@JohnKeating24

This comment has been minimized.

Show comment
Hide comment
@JohnKeating24

JohnKeating24 May 10, 2017

@OuYag I followed your advice and did according to your setting.And after several steps , it finally works. Thank you very much , you did help me a lot! (:

JohnKeating24 commented May 10, 2017

@OuYag I followed your advice and did according to your setting.And after several steps , it finally works. Thank you very much , you did help me a lot! (:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment