-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Improved CMake scripts #1667
Improved CMake scripts #1667
Conversation
60e8f7a
to
10b8523
Compare
Nerei@60e8f7a#commitcomment-9141630 According to this @longjon 's comment, I reverted last commit where I had reduced NumPy requirements from 1.7.1. to 1.6.1. But now python interface compilation is not tested by Travis CI. Need to update numpy there. |
10b8523
to
bb19ef9
Compare
Re: numpy versions, Travis should use a recent version after #1473. (If we want to build pycaffe with these CMake updates before that, the Travis build script could be modified to force CMake to go ahead with an older version, either by some CMake switch that I don't know, or by actually updating the CMake script before the build.) |
I noticed that some tasty python features are being implemented (Once they're done, I'm ready to prepare new PR with its support) |
@Nerei thanks for the effort to improve the CMake build and align it with the features of the Makefile. Nice to have the pieces in place to include Caffe in other projects too. Regarding the shared or static library build, I'd rather the shared library be the default since it is used more commonly (right?). |
👍 for shared default |
Absolutely agree that shared is better! Just it was for similarity with previous vesion. |
e9adae7
to
1fc6f2c
Compare
@Nerei I'm guessing what is the support status for windows generators with this refactoring. Working VS generators could help people at #15 |
Great work @Nerei! Is this ready for review or are there further changes planned for this PR? (Of course more can be done in follow ups, such as CMake support for the new Python features that are on track for merge.) |
To: @bhack CC: @shelhamer @Yangqing Absolutely, agree that can use windows generators with cmake. But now I don't think that windows is currently supported by caffe without modifications. If you compile caffe as dynamic library, Attribute For Windows, one may try |
@shelhamer Thanks! I think it's ready for review. At least future changes, like windows support or improvements, I would cover in separate PR. I think better to fetch the branch and review cmake-files locally, it should be easy to read. I wanted to write them as very readable, all difficulties are separated as macros, most of which I just copy-pasted from my projects and opencv. My aim was to create some well done basis/style and standardize it, so that it would be clear where/how to write changes in future. |
Regarding windows, I might be worth creating a repository with cmakeified dependencies so that one can compile and use use the dependencies for caffe compilation "in couple clicks". I can help with this since I am primary a windows user. |
@bhack Interesting. But cmake scripts are required to be written anyway. And this cross-compile tool uses mingw (gcc port to windows), and its output can't be used from Visual Studio, only from mingw. |
@Nerei VS generators are a feature of cmake. FindScripts need to be written or copied by other BSD project for correct multiplatform support (ones that are not already distributed by Cmake). Mxe is only for building easly I.e. widows dependencies from Linux or easily compiling caffe for windows target in Linux with almost the actual infrastructure. |
Yes. you're completely right, you can compile caffe.exe from linux for windows and use the executable. there. But not cafe.lib to link into your Visual Studio application. The same with dependencies. |
Static library are directly supported in VS. Also dynamic ones are supported with some additional steps |
Please ask on caffe forums. Actually you should set Caffe_DIR to caffe build directory, not source one. |
Hi all, I have installed caffe and have tested with a mnist script. That one is working, also with the gpu :) Now, I am trying to work with the matlab interface. I am testing with the basic demo from CAFFE_FOLDER/matlab/demo However, I am getting the error: [libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.0.0 of the Protocol Buffer runtime library, but the installed version is 2.5.0. Please update your library. If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library. (Version verification failed in "google/protobuf/any.pb.cc".) I have verified that I have the proto version 3.00 in my path with 'protoc --version' in console and also in matlab with unix('protoc --version') and I am getting version 3.00. However, still has the previous error. Any suggestions ? Thanks. |
I am continuously getting this error while trying to install Caffe using CMake: Please help! |
Hello, I am trying to use Caffe API in my project in visual studio but I have the same issue as @InfiniteLifeH has, @Nerei I set Caffe_DIR to build and still have the problem. I am getting this warning in Cmake : CMake Warning at (find_package): Could not find a package configuration file provided by "Caffe" with any of
Add the installation prefix of "Caffe" to CMAKE_PREFIX_PATH or set Thanks, |
hi, can anyone help me for this error? [----------] 2 tests from BatchReindexLayerTest/1, where TypeParam = caffe::CPUDevice [----------] 5 tests from ImageDataLayerTest/1, where TypeParam = caffe::CPUDevice [----------] Global test environment tear-down 1 FAILED TEST |
it's not working. |
i run into this problem:
any idea? thanks a lot ^_^ |
try compiling with -fPIC ? flow ir in On 5 October 2016 at 14:09, EmpireofQin [email protected] wrote:
|
I have tried this, but dosen't work |
what is the error? flow ir in On 7 October 2016 at 14:21, EmpireofQin [email protected] wrote:
|
I have solved this problem. I tried to edit CMakeCache.txt in the build file and changed
into
and it works. |
@riteshpradh |
@longjon |
Hi, I have error like this:
I can still do next steps to finish compiling. What should I do to solve this error? |
Who can tell me how to use intel mkl to compile caffe with cmake???? |
@viscropst In case you are still wondering, to build w/ Intel MLK, you can do the following: |
Compilation crushed on the following errors. Can anyone help?
|
can anyone help me with this problem when I "make runtest"? [----------] Global test environment tear-down 1 FAILED TEST |
@InfiniteLifeH have you succeed in windows? |
Can anyone help me with this problem when I "make install"? Thanks a lot. CMake Error at python/cmake_install.cmake:59 (file):
to the file:
The current RPATH is:
which does not contain:
as was expected. Makefile:61: recipe for target 'install' failed |
how can i change CPU_ONLY :OFF to CPU_ONLY:ON before make cmake.. ??? |
cmake -DCPU_ONLY=ON .....
…On Tue, Nov 14, 2017 at 10:24 AM, Egor ***@***.***> wrote:
how can i change CPU_ONLY :OFF to CPU_ONLY:ON before make cmake.. ???
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1667 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AEoQUeF8Fr_3CahavWikmcCMdzS6ebWMks5s2drjgaJpZM4DNzQk>
.
--
Yang Chen
GPG ID: F0673B36
|
I have made caffe with cmake, however when I try to make pycaffe, all the file installed in my directory:build/install disappear. Can anybody help me ? |
I met the problem |
Hi I am trying to install the https://github.com/microideax/Quantization-caffe repository, which have referred to follow what has been said here. However, I am getting the below error: Can anyone help me with this? Thank you very much. |
@shelhamer @jeffdonahue @baeuml @kloudkl @akosiorek @Yangqing @BlGene
Hello all,
hope I referenced everyone who participated cmake development (at least I didn't find others)
Following discussion here #1586, as I promised, I prepared slightly improved caffe cmake scripts. The improvement was developed using Ubuntu 14.04 and tested on Yosemite (with libstdc++). I believe Windows support now is as difficult as compiling all dependencies. But I prefer to postpone testing on Windows until current very linux-ish build scripts and behaviour are slightly adapted for cross-platform use and some dependencies are made optional.
Description of changes and new features added
Added OpenCV like formatted configuration log
https://travis-ci.org/BVLC/caffe/jobs/45700248
Added CaffeConfig.cmake generation for build/install cases.
This allows you to connect Caffe to your application using CMake's
find_package(Caffe)
. For more detailed description see below.BUILD_SHARED_LIB=ON (default) or OFF
build caffe as shared library. In CMake it not good practice to build both shared and static simultaneously. That’s why the switch.
CPU_ONLY = OFF(default) or ON
Forces excluding CUDA support. Also Caffe will compile in
CPU_ONLY
mode if CUDA Toolkit is not installed or found by cmake. Before build please read chic configuration log dumped by cmake to control this case.USE_CUDNN = ON (default)
If enabled and
cudnn
is found build with it, otherwise build without.CUDA_ARCH_NAME=Auto(default), All, Fermi, Kepler, Maxwell, Manual
specifies target GPU architecture, Selecting concrete value reduces CUDA code compilation time (for instance compilation for sm_20 and sm_30 is twice longer than just for one of them). In case of Auto, cmake will make an attempt to detect GPUS installed in your computer and compile only for them. In case of manual, new
CUDA_ARCH_BIN/PTX
cmake variables are created where space separated list of architectures should be set. Example,CUDA_ARCH_BIN=”20 21(20) 50”
BUILD_docs = ON (default)
make docs
to build andmake jekyll
to run web server. html docs are built in<source folder>/doxygen
, and next symlink is created in<source folder>/docs/doxygen
. Functionality fromscripts/gather_examples.sh
is now implemented incmake
, butcopy_notebook.py
is still required..Doxyfile
contains relative paths and I prefer not to modify it now, but think generation in binary folder is betterBUILD_python = ON (default)
Build python interface if all required dependencies found, otherwise excluded from build automatically
BUILD_matlab = OFF(default)
Enables building matlab interfaces. Currently it supports both Octave and Matlab. For Octave set
Octave_compiler
to mkoctfile if not found automatically. For Matlab specifyMatlab_DIR
orMatlab_mex
andMatlab_mexext
if again not found automatically. If both installed and found, to select which one to use, setMatlab_build_mex_using=Matlab(default) or Octave
. Note matlab wrappers can only be built ifBUILD_SHARED_LIB=On
. On macos both doesn’t compile.Proto-files
Now protobuf files ARE NOT copied to
<caffe_root>/include/caffe/proto
anymore. Instead they are generated to<build_dir>/include/caffe/proto
. Know one may include old headers, but this is interest rates to payback of technical debt appeared due to incorrect original cmake scripts design. Also removed them from.gitignore
test.testbin
cmake_test_defines.hpp
andsample_data_list.txt
are configured by cmake to source directory and NO-DCMAKE_BUILD
definition added and all*.in
templates were removed. This is becausemake runtest
command is executed in source directory, and embedding absolute paths to test cpp-files is not required! Consider configure_file() to source folder as antipattern. However, one may return such embedding by uncommenting couple lines insrcs/test/CMakeLists.txt
.-DBUILD_only_tests=="common,net,blob,im2col_kernel"
Yosemite support
I was able to compile with CUDA support using the Caffe instruction with libstdc++ and patching opencv as here opencv/opencv@32f6e1a.
Accelerate.framework
support added. Matlab interface was failed to compile.Temporary changes
make symlink
creates symlink[caffe_root]/build -> cmake_build_directory
.bin
suffix and next symlink with.bin
suffix created nearby. So that tutorials could work. Once naming standardized, should remove this.Including Caffe in your CMake project via find_package()
Verify that cmake found everything and in proper locations. After can run
make -j 12
right now or better do this:After the operations complete, caffe tutorials should work from caffe root directory. Let’s now see how to connect caffe to a C++ application that uses Caffe API with cmake. Prepare the following script:
Run CMake to configure this application and generate build scripts or IDE project. It will automatically find Caffe in its build directory and pick up all necessarily dependencies (includes, libraries, definitions) and application will compile without any additional actions. Caffe dependencies will also have been included. If you have several Caffe builds or for some reason Cmake wasn’t able find Caffe automatically, you may specify
Caffe_DIR=<path-to-caffe-build-dir>
in Cmake and this guarantees that everything will work.Specified Caffe_DIR to build directory leads to always using a build configuration (say, Release or Debug) Caffe compiled last time for. If you set
Caffe_DIR=<caffe-install-dir>/share/Caffe
where both configurations have been installed, proper debug or release caffe binaries will be selected depending on for which configuration you compile yourcaffeinated_application
.Enjoy!!
(Fixed typos in CUDA architectures - @Noiredd)