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

Separate dependencies for configurable installation #2523

Merged
merged 3 commits into from
Sep 17, 2015
Merged

Separate dependencies for configurable installation #2523

merged 3 commits into from
Sep 17, 2015

Conversation

eelstork
Copy link
Contributor

Addresses #1738.
The PR benefited earlier attempts by @cypof (#2402) and @kloudkl (#1074).
Options provided include USE_OPENCV, USE_LMDB, USE_LEVELDB, USE_HDF5, USE_SNAPPY, with both make and CMake flags available.
This allows selecting which IO libraries to build with. Wherever possible functions that would behave incorrectly as a result of disabling a library are excluded before runtime.

Added two items to the test matrix:
- WITH_CUDA=false WITH_CMAKE=false WITH_IO=false
- WITH_CUDA=false WITH_CMAKE=true WITH_IO=false

Without bloating the test matrix, it is essential to have at least one of these, otherwise correct separation of these dependencies would be unmaintainable.

@flx42
Copy link
Contributor

flx42 commented May 28, 2015

Instead of adding patches fixing your own mistakes, squash multiple patches in one patch and force push to your branch to update the PR.

@bhack
Copy link
Contributor

bhack commented May 29, 2015

/cc @Nerei

if(USE_LMDB)
caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No")
endif()
if(USE-SNAPPY)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@shelhamer
Copy link
Member

@eelstork do keep hacking at this! It will be great to have separate dependencies in line with #1738.

@Nerei
Copy link

Nerei commented May 29, 2015

This PR doesn't generate proper CaffeConfig.cmake. All such definitions should be propagated to client code too.

@eelstork
Copy link
Contributor Author

@Nerei thanks for the many helpful suggestions. Working on this.

@eelstork
Copy link
Contributor Author

eelstork commented Jun 3, 2015

@Nerei the forward declaration of cv::Mat would not be helpful since cv:Mat will not be available at runtime?

@Nerei
Copy link

Nerei commented Jun 3, 2015

@eelstork Agree. If user try to call opencv dependent method, it will get link errors. Well this is all up to code organization. In general, It's preferable to hide as much as possible USE_* defines into cpp, but this might require more significant caffe code change. That's IMHO.

Regarding commit c5ebe85, I think it should be reverted. Such config should be included into each header (otherwise that defines are always undefined) but it is not generated by Make. I put my comment above and then disproved it.

@eelstork
Copy link
Contributor Author

eelstork commented Jun 5, 2015

@Nerei referring c5ebe85, If add_definitions() is not portable this may need fixing later but for now caffe_config.h appears to be somewhat ineffective. I would suggest that we leave things as-is (consistent with handling of 'CPU_ONLY' flag).

@eelstork
Copy link
Contributor Author

eelstork commented Jun 5, 2015

@Nerei please have a look at the generated CaffeConfig.cmake; if this is not appropriate, I welcome suggestions to improve it.

@eelstork
Copy link
Contributor Author

eelstork commented Jun 5, 2015

Pending further feedback, standing by.

@flx42
Copy link
Contributor

flx42 commented Jun 5, 2015

Please squash the patches, it's difficult to review right now.

@Nerei
Copy link

Nerei commented Jun 7, 2015

Fine with CaffeConfig.cmake

@bhack
Copy link
Contributor

bhack commented Jun 10, 2015

@eelstork Can you rebase and squash?

@eelstork
Copy link
Contributor Author

@bhack @flx42 squashed #2523

@keenbrowne
Copy link

@shelhamer @bhack @flx42 @eelstork
What work is left to get this merged? We would like to depend on these changes in our caffe based application.

@eelstork
Copy link
Contributor Author

@shelhamer @keenbrowne ready for review/merge.

USE_HDF5 := 1 # {IO-flag}
USE_OPENCV := 1 # {IO-flag}
USE_SNAPPY := 1 # {IO-flag}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trailing comments (# {IO-flag}) might cause problems for value evaluation.

@bhack
Copy link
Contributor

bhack commented Jun 18, 2015

@eelstork Have you tested if with this new modularity can build with androd-cmake: https://github.com/taka-no-me/android-cmake/blob/master/README.md?

@bhack
Copy link
Contributor

bhack commented Jun 18, 2015

@sh1r0 This add also apk generation capabilties: https://github.com/Discordia/android-cmake

@eelstork
Copy link
Contributor Author

Removed trailing comments in makefile.config. Thanks to @sh1r0 for the suggestion.

@eelstork
Copy link
Contributor Author

@bhack No, I haven't; nor do I know whether it was possible before? Although we hope that removing the dependencies will help porting Caffe to other platforms, I believe that compatibility with a specific platform/config should be addressed separately.

@bhack
Copy link
Contributor

bhack commented Jun 18, 2015

@eelstork Yes of course. I've asked only if somebody tested it with this modularization to know now if could be any other modularization that could improve the process with android NDK.

@bhack
Copy link
Contributor

bhack commented Sep 4, 2015

@jeffdonahue @shelhamer What do you think of the related #2619?

@eelstork
Copy link
Contributor Author

eelstork commented Sep 8, 2015

@shelhamer and @jeffdonahue thanks for these suggestions, I have made changes accordingly (see relevant commits); squash?
Pending review/merge.

@shelhamer
Copy link
Member

Thanks @eelstork! This looks good to me, so please squash for merge. However 526372a can stay its own commit to explain Travis CI is CPU-only although the message should change to reflect that.

@eelstork
Copy link
Contributor Author

eelstork commented Sep 9, 2015

@shelhamer Thanks! Before letting go, I suggest we drop the option to explicitly enable/disable snappy. This is because caffe does not directly depend on Snappy, instead, it is LevelDB that requires it. Where build scripts relied on associate flag, USE_LEVELDB would be used instead. Intending to push a commit to illustrate proposed solution.

@eelstork
Copy link
Contributor Author

eelstork commented Sep 9, 2015

@shelhamer @jeffdonahue @bhack @Nerei, opinions about 58f017e ?

@shelhamer
Copy link
Member

@eelstork 584f017e is good, but please squash with a5bdc06 and add an explanatory commit message that lists the new flags and explain that leveldb + snappy are coupled since snappy is just a leveldb dependency. Thanks.

@eelstork
Copy link
Contributor Author

@shelhamer - updated; squashed.

@eelstork
Copy link
Contributor Author

@shelhamer Anything missing to get this merged?

@jeffdonahue
Copy link
Contributor

@eelstork I took another look -- sorry for the last minute comments. Otherwise looks good for merge to me.

OpenCV, LMDB, LevelDB and Snappy are made optional via switches
(USE_OPENCV, USE_LMDB, USE_LEVELDB) available for Make and CMake
builds. Since Snappy is a LevelDB dependency, its use is determined by
USE_LEVELDB. HDF5 is left bundled because it is used for serializing
weights and solverstates.
@eelstork
Copy link
Contributor Author

@jeffdonahue updated. I would suggest leaving 2349c6d as a separate commit.

@jeffdonahue
Copy link
Contributor

Thanks @eelstork!

jeffdonahue added a commit that referenced this pull request Sep 17, 2015
Separate dependencies for configurable installation
@jeffdonahue jeffdonahue merged commit 5ff3734 into BVLC:master Sep 17, 2015
@bhack
Copy link
Contributor

bhack commented Sep 17, 2015

@jeffdonahue Can you take a look at related #2619?

@shelhamer
Copy link
Member

@mtngld thanks for pointing this out.

@jeffdonahue thoughts on making all IO on by default for backwards compatibility? The Makefile.config / CMake can then explicitly disable dependencies as desired. That seems reasonable to me.

@jeffdonahue
Copy link
Contributor

Oops, I didn't realize this changed the default to no IO dependencies. Yes, I agree the default should be to have them all enabled as before.

@d4nst
Copy link

d4nst commented Oct 30, 2015

Currently it is not possible to disable leveldb and lmdb (at least on Windows) which would be useful to use Caffe for deployment only.

@eelstork
Copy link
Contributor Author

@danst18 I believe that disabling LevelDB and LMDB is possible on Windows (via CMake), granted that building caffe on Windows does require tweaks. What motivates your comment?

@d4nst
Copy link

d4nst commented Oct 31, 2015

@eelstork I mean when both of them are disabled at the same time. In db.cpp I get an error saying that GetDB should return a value. If I remove db.h and db.cpp then I have to add guards to other parts of the code where they are referenced, for example in data_reader.cpp

@eelstork
Copy link
Contributor Author

eelstork commented Nov 8, 2015

@danst18 sorry for the late reply. I submitted a fix for this. Thank you for reporting the issue.

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

Successfully merging this pull request may close these issues.

10 participants