Skip to content
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

[Caffe2] How to link Caffe2 in cmake file for C++ compilation? #15004

Open
pjavia-iterativescopes opened this issue Dec 10, 2018 · 4 comments
Open
Labels

Comments

@pjavia-iterativescopes
Copy link

pjavia-iterativescopes commented Dec 10, 2018

I tried-->find_package(Caffe2 REQUIRED)

Here is the error

By not providing "FindCaffe2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Caffe2", but
CMake did not find one.

Could not find a package configuration file provided by "Caffe2" with any
of the following names:

Caffe2Config.cmake
caffe2-config.cmake

Add the installation prefix of "Caffe2" to CMAKE_PREFIX_PATH or set
"Caffe2_DIR" to a directory containing one of the above files. If "Caffe2"
provides a separate development package or SDK, be sure it has been
installed.

@beichen2012
Copy link

try:
list(APPEND CMAKE_PREFIX_PATH "/your caffe2 install path")
find_package(Caffe2)

@pjavia-iterativescopes
Copy link
Author

pjavia-iterativescopes commented Jan 2, 2019

I found Caffe2Config.cmake . The problem is there are many locations where its located and I tried setting Caffe2_DIR with all possible location but the real problem is all the header files relative paths are set properly. I mean if I got to Caffe2/core/init.h there are include files whose relative path is not accurate. How to tackle this ?
Here is folder structure.
If I set Caffe2Config.cmake from build folder it throws error as the relative path inside the file are messed up.
pytorch
--aten
--binaries
--build/Caffe2Config.cmake
--c10
--caffe2/core
--cmake
--docker
--docs
--modules
--scripts
--submodules
--test
--torch/share/cmake/Caffe2Config.cmake

@pjavia-iterativescopes
Copy link
Author

@beichen2012 The Caffe2_DIR = ~/pytorch/build/Caffe2Config.cmake does not relative path correct as there is no folder named “public” in the current directory

Also if I set Caffe2_DIR= ~/pytorch/torch/share/cmake/Caffe2Config.cmake then also cmake does not include and files. I had to manually include it.

Finally I am getting linking errors. Which are the libraries I should link and in which order. Please guide I am working hard just to run a simple code using Caffe2 C++ more than a week.

@beichen2012
Copy link

@beichen2012 The Caffe2_DIR = ~/pytorch/build/Caffe2Config.cmake does not relative path correct as there is no folder named “public” in the current directory

Also if I set Caffe2_DIR= ~/pytorch/torch/share/cmake/Caffe2Config.cmake then also cmake does not include and files. I had to manually include it.

Finally I am getting linking errors. Which are the libraries I should link and in which order. Please guide I am working hard just to run a simple code using Caffe2 C++ more than a week.

cd your pytorch source code dir, then mkdir build, cd build , cmake -DCMAKE_INSTALL_PREFIX=/opt/Caffe2 .. , then: make && sudo make install.
the path: /opt/Caffe2 IS YOUR CAFFE2 INSTALL PATH,
list(APPEND CMAKE_PREFIX_PATH "/opt/Caffe2"),
THEN: find_package(Caffe2),
THAT WILL BE OK .

please refer to : "https://github.com/beichen2012/testMultiThreadCaffe2"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants