davheld / GOTURN

Source code for paper: Learning to Track at 100 FPS with Deep Regression Networks, Held, et al. ECCV 2016
http://davheld.github.io/GOTURN/GOTURN.html
MIT License
886 stars 316 forks source link

How to add caffe using CMake #4

Open gaopeng-eugene opened 8 years ago

gaopeng-eugene commented 8 years ago

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 commented 8 years ago

same problem here :s

davheld commented 8 years ago

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 commented 8 years ago

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 https://github.com/davheld/GOTURN/issues/4#issuecomment-244943186, or mute the thread https://github.com/notifications/unsubscribe-auth/AEHoHBuK5qtcr5HJDpR9_l4JQ16sj2Nvks5qnWTHgaJpZM4JpCjy .

metropt commented 8 years ago

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 commented 8 years ago

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

metropt commented 8 years ago

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 commented 8 years ago

https://github.com/davheld/GOTURN/pull/9

Ouya-Bytes commented 8 years ago

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

metropt commented 8 years ago

@OuYag take a look at #14

Ouya-Bytes commented 8 years ago

@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 commented 8 years ago

@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 commented 8 years ago

With respect to #include 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 commented 8 years ago

@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 ).

Ouya-Bytes commented 8 years ago

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 commented 8 years ago

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

vj-1988 commented 8 years ago

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 commented 7 years ago

@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 commented 7 years ago

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

Ouya-Bytes commented 7 years ago

@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 commented 7 years ago

@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! (:

gsethi2409 commented 4 years ago

Hey! I was able to resolve the ${Caffe_DIR}/include) issue but CMake is unable to find ${Caffe_DIR}/lib. Trying to install and configure openpose on MAC (CPU only).

This is my FindCaffe.CMake:

unset(Caffe_FOUND)

###Set the variable Caffe_DIR as the root of your caffe directory
set(Caffe_DIR /Users/gsethi2409/openpose/3rdparty/caffe)

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()

Please heeellllpppp!

nrupatunga commented 4 years ago

@gsethi2409

not sure about lib path in Mac.

Just check where libcaffe.so is built.

On ubuntu machine it is {Caffe_DIR}/build/lib)

gsethi2409 commented 4 years ago
# Import the targets
include("${_prefix}/lib/OpenPose/OpenPose.cmake")
if (@BUILD_CAFFE@)
  set(Caffe_INCLUDE_DIRS "${_prefix}/include/")
  # set(Caffe_LIBS "${_prefix}/lib/libcaffe.so")
endif (@BUILD_CAFFE@)

Thanks for the prompt reply! Found this piece of code in OpenPoseConfig.cmake.in inside the cmake folder. Am I supposed to uncomment this - # set(Caffe_LIBS "${_prefix}/lib/libcaffe.so")

nrupatunga commented 4 years ago

Not sure about OpenPose, But yeah looks like you need to uncomment that code.