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

Which layer headers to include, depending on Caffe's version? #3409

Closed
GiuliaP opened this issue Dec 3, 2015 · 6 comments
Closed

Which layer headers to include, depending on Caffe's version? #3409

GiuliaP opened this issue Dec 3, 2015 · 6 comments

Comments

@GiuliaP
Copy link

GiuliaP commented Dec 3, 2015

Hi,

after the recent re-organization of Caffe's headers, our code using Caffe does not compile anymore. I updated some of our modules accordingly to the new policy and now they compile (for instance, I modified those modules including the file caffe/vision_layers.hpp to include specific files for each layer).

The problem is that we cannot ensure that all the users of our code in different labs are linking to the same Caffe version/commit: is there any way to detect whether the Caffe version is the new one or not, and include files accordingly?

Thanks,
Giulia

@lukeyeager
Copy link
Contributor

Plug for versioning! #3311

@shelhamer
Copy link
Member

Right now the only versioning information is the commit ID in the git repo. However @lukeyeager has kindly contributed the machinery for release versioning in #3311.

We plan to adopt it and make release branches but have not had a chance to yet.

Instead of waiting for 1.0 it seems like it could do good to adopt the new release workflow now for a series of release candidate (RC) versions while we cross off our 1.0 TODOs.

@GiuliaP
Copy link
Author

GiuliaP commented Dec 21, 2015

Ok thanks, I didn't understand your last comment but I think it wasn't for me, right?

I am updating all of our code in any case, as it seems that these changes that you made to the headers will be permanent. Then I'll wait for release versioning!

@GiuliaP
Copy link
Author

GiuliaP commented Dec 30, 2015

I post this here because the problem is related to this issue. Indeed it raised once I pulled Caffe and changed the header inclusions in our code accordingly to use the new Caffe headers. Nevertheless, I am aware that this could be a different issue.

As I anticipated in previous posts, I updated Caffe on our machine by pulling from the repository (commit 03a84bf) and updated the inclusions of our code to use the new headers. What I observed is an impressive slowdown in the time for feature extraction with C++ code with respect to the older version of Caffe that we were using (commit 77ab8f6)! As we use Caffe on robots, for us speed of feature extraction and the real-time requirement are important factors.

In the following I explain the problem more precisely.

Both versions of Caffe are running on the same machine, with the same dependencies. In particular, device: Tesla k40c, drivers: 340.29, CUDA toolkit: 6.5.
Also the other dependencies (OpenCV 2.4.10, OpenBLAS 0.2.13, Boost 1.55) are the same. For completeness, at the end of this post I report the CMake configurations for the two different Caffe versions I tried.
Now the problem is that feature extraction (fc6) with CaffeNet (bvlc_reference_caffenet) from a single frame at a time (no batches) takes around 12ms with the "old" Caffe and more than 200ms with the "new" one. The only difference between the two is that for the "new" one I do not make use of cuDNN, because I should use cuDNN version 3.0, and hence upgrade the CUDA Toolkit to 7.5 and drivers. However, I have performed other experiments which I reported here: robotology/himrep#10. As you can see, in order to obtain again around 30ms per frame, I had to upgrade on the machine the toolkit + drivers. Moreover, I wasn't able to obtain again 12ms, unless switching to float instead of double precision, whereas with the old version I was using double precision. I also observed that the fact of disabling cuDNN cannot explain so much difference (from 10ms to 200ms..?).

Do you have any clues?

Thanks,
Giulia

"old" version:
-- ******************* Caffe Configuration Summary *******************

-- General:

-- Version : (Caffe doesn't declare its version in headers)

-- Git : rc2-105-g77ab8f6

-- System : Linux

-- C++ compiler : /usr/bin/c++

-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized

-- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized

-- Build type : Release

-- BUILD_SHARED_LIBS : ON

-- BUILD_python : ON

-- BUILD_matlab : OFF

-- BUILD_docs : ON

-- CPU_ONLY : OFF

-- Dependencies:

-- BLAS : Yes (Open)

-- Boost : Yes (ver. 1.55)

-- glog : Yes

-- gflags : Yes

-- protobuf : Yes (ver. 2.5.0)

-- lmdb : Yes (ver. 0.9.10)

-- Snappy : Yes (ver. 1.1.0)

-- LevelDB : Yes (ver. 1.15)

-- OpenCV : Yes (ver. 2.4.10)

-- CUDA : Yes (ver. 6.5)

-- NVIDIA CUDA:

-- Target GPU(s) : Auto

-- GPU arch(s) : sm_35 sm_30

-- cuDNN : Yes

-- Documentaion:

-- Doxygen : No

-- config_file :

"new" version:

-- ******************* Caffe Configuration Summary *******************

-- General:

-- Version : (Caffe doesn't declare its version in headers)

-- Git : rc2-738-g03a84bf

-- System : Linux

-- C++ compiler : /usr/bin/c++

-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized

-- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized

-- Build type : Release

-- BUILD_SHARED_LIBS : ON

-- BUILD_python : ON

-- BUILD_matlab : OFF

-- BUILD_docs : ON

-- CPU_ONLY : OFF

-- USE_OPENCV : ON

-- USE_LEVELDB : ON

-- USE_LMDB : ON

-- ALLOW_LMDB_NOLOCK : OFF

-- Dependencies:

-- BLAS : Yes (Open)

-- Boost : Yes (ver. 1.55)

-- glog : Yes

-- gflags : Yes

-- protobuf : Yes (ver. 2.5.0)

-- lmdb : Yes (ver. 0.9.10)

-- LevelDB : Yes (ver. 1.15)

-- Snappy : Yes (ver. 1.1.0)

-- OpenCV : Yes (ver. 2.4.10)

-- CUDA : Yes (ver. 6.5)

-- NVIDIA CUDA:

-- Target GPU(s) : Auto

-- GPU arch(s) : sm_35 sm_30

-- cuDNN : Disabled

-- Documentaion:

-- Doxygen : No

-- config_file :

@shelhamer
Copy link
Member

Done in #3311 by the SONAME version although a version header could still be added.

@GiuliaP
Copy link
Author

GiuliaP commented Apr 5, 2016

@shelhamer Thank you. How can I retrieve the version from a CMakeLists.txt that links to caffe?

I have tried the following:

find_package(Caffe)
include_directories(${Caffe_INCLUDE_DIRS})
add_definitions(${Caffe_DEFINITIONS})
...
get_target_property(version caffe VERSION)
message( STATUS "VERSION is: " ${version})
add_definitions( -DCAFFE_VERSION=${version} )

and it does not find the property. Instead it manages to find:

...
get_target_property(soname caffe IMPORTED_SONAME_RELEASE)
message( STATUS "SONAME is: " ${soname})
add_definitions( -DCAFFE_VERSION=${soname} )

Now I am wondering what is the correct procedure to obtain the CAFFE_VERSION variable defined and usable when I include headers.

Thanks again
Giulia
PS: should I open another issue or ask to Caffe Users?

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

No branches or pull requests

3 participants