Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Separate dependencies for configurable installation #2523
Conversation
shelhamer
added compatibility build
labels
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. |
|
/cc @Nerei |
Nerei
commented on an outdated diff
May 29, 2015
| caffe_status(" protobuf : " PROTOBUF_FOUND THEN "Yes (ver. ${PROTOBUF_VERSION})" ELSE "No" ) | ||
| - caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No") | ||
| - caffe_status(" Snappy : " SNAPPY_FOUND THEN "Yes (ver. ${Snappy_VERSION})" ELSE "No" ) | ||
| - caffe_status(" LevelDB : " LEVELDB_FOUND THEN "Yes (ver. ${LEVELDB_VERSION})" ELSE "No") | ||
| - caffe_status(" OpenCV : Yes (ver. ${OpenCV_VERSION})") | ||
| + if(USE_LMDB) | ||
| + caffe_status(" lmdb : " LMDB_FOUND THEN "Yes (ver. ${LMDB_VERSION})" ELSE "No") | ||
| + endif() | ||
| + if(USE-SNAPPY) |
|
|
Nerei
commented on an outdated diff
May 29, 2015
| @@ -24,24 +24,36 @@ list(APPEND Caffe_LINKER_LIBS ${GFLAGS_LIBRARIES}) | ||
| include(cmake/ProtoBuf.cmake) | ||
| # ---[ HDF5 | ||
| -find_package(HDF5 COMPONENTS HL REQUIRED) | ||
| -include_directories(SYSTEM ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR}) | ||
| -list(APPEND Caffe_LINKER_LIBS ${HDF5_LIBRARIES}) | ||
| +if(USE_HDF5) | ||
| + find_package(HDF5 COMPONENTS HL REQUIRED) | ||
| + include_directories(SYSTEM ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR}) | ||
| + list(APPEND Caffe_LINKER_LIBS ${HDF5_LIBRARIES}) | ||
| + add_definitions(-DUSE_HDF5) |
Nerei
|
Nerei
commented on an outdated diff
May 29, 2015
| @@ -65,8 +65,10 @@ private:\ | ||
| // is executed we will see a fatal log. | ||
| #define NOT_IMPLEMENTED LOG(FATAL) << "Not Implemented Yet" | ||
| +#ifdef USE_OPENCV |
Nerei
|
Nerei
commented
May 29, 2015
|
This PR doesn't generate proper CaffeConfig.cmake. All such definitions should be propagated to client code too. |
|
@Nerei thanks for the many helpful suggestions. Working on this. |
bhack
referenced
this pull request
Jun 2, 2015
Closed
First attemp to remove boost dependecies. #2537
|
@Nerei the forward declaration of cv::Mat would not be helpful since cv:Mat will not be available at runtime? |
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 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. |
|
@Nerei please have a look at the generated CaffeConfig.cmake; if this is not appropriate, I welcome suggestions to improve it. |
|
Pending further feedback, standing by. |
|
Please squash the patches, it's difficult to review right now. |
Nerei
commented
Jun 7, 2015
|
Fine with CaffeConfig.cmake |
|
@eelstork Can you rebase and squash? |
This was referenced Jun 12, 2015
keenbrowne
commented
Jun 17, 2015
|
@shelhamer @bhack @flx42 @eelstork |
|
@shelhamer @keenbrowne ready for review/merge. |
sh1r0
commented on an outdated diff
Jun 18, 2015
| @@ -7,6 +7,13 @@ | ||
| # CPU-only switch (uncomment to build without GPU support). | ||
| # CPU_ONLY := 1 | ||
| +# Comment out to disable IO dependencies | ||
| +USE_LEVELDB := 1 # {IO-flag} | ||
| +USE_LMDB := 1 # {IO-flag} | ||
| +USE_HDF5 := 1 # {IO-flag} | ||
| +USE_OPENCV := 1 # {IO-flag} | ||
| +USE_SNAPPY := 1 # {IO-flag} | ||
| + |
sh1r0
Contributor
|
|
@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? |
|
@sh1r0 This add also apk generation capabilties: https://github.com/Discordia/android-cmake |
|
Removed trailing comments in makefile.config. Thanks to @sh1r0 for the suggestion. |
|
@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. |
|
@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. |
sh1r0
referenced
this pull request
Jun 18, 2015
Closed
Make HDF5 components optional for configurable build #2619
|
I really hope that we are not starting to income in a preprocessor abuse syndrome caused by bad code modularization design. |
|
Android effort started at #2619 |
|
@bhack We need more information (and more time/resources) to improve modularisation design. Imho, directives can help transition towards a better design later. |
|
Rebased, squashed. Still awaiting review/merge. |
|
@eelstork You need to wait. The status of core devs It is still unkown. The last know one was CVPR 2015 and there is no community management other than core devs and occasional BVLC traiger students. |
shelhamer
commented on the diff
Jul 29, 2015
| @@ -1,3 +1,4 @@ | ||
| +#ifdef USE_OPENCV |
shelhamer
Owner
|
shelhamer
commented on an outdated diff
Jul 29, 2015
| @@ -2889,6 +2889,7 @@ TEST_F(NetUpgradeTest, TestImageNet) { | ||
| this->RunV1UpgradeTest(expected_v1_proto, expected_v2_proto); | ||
| } // NOLINT(readability/fn_size) | ||
| +#if defined (USE_OPENCV) && defined(USE_HDF5) |
shelhamer
Owner
|
shelhamer
commented on an outdated diff
Jul 29, 2015
| @@ -115,5 +116,8 @@ int main(int argc, char** argv) { | ||
| } | ||
| LOG(INFO) << "mean_value channel [" << c << "]:" << mean_values[c] / dim; | ||
| } | ||
| +#else | ||
| + LOG(FATAL) << "Compile with OpenCV to use this."; |
shelhamer
Owner
|
shelhamer
commented on an outdated diff
Jul 29, 2015
|
@eelstork thanks for splitting the dependencies! @longjon @jeffdonahue and I agree that it is better to separate IO. I defer to @Nerei regarding the CMake changes; I only know the Makefile (and that looks fine). hdf5 can be left bundled since we plan to switch to it for serializing weights and solverstates to fix #2006. Since the Makefile is more simple, the test matrix could include the CMake == true, IO == false case to catch more issues if the two make testing too slow. |
Nerei
commented
Jul 31, 2015
|
CMake changes look fine for me. |
|
@shelhamer about hdf5: currently, default config is with all dependencies enabled to maintain backwards compatibility. @shelhamer @Nerei thanks for your feedback, I will update, resolve conflicts and resubmit for review/merge. |
bhack
referenced
this pull request
in bytedeco/javacpp-presets
Aug 14, 2015
Merged
Build Caffe on CentOS 6 with dependencies included #77
|
Actually hdf5 it is the new default model format. So it is an hard dependency for Caffe and cannot be modularized anymore if we not want to fallback to proto. So actually if we follow the defaults the minimal dependencies of caffe are increased. |
shelhamer
referenced
this pull request
Aug 26, 2015
Closed
Enable the users to disable optional dependencies #1074
|
Is this mergiable? |
|
@bhack I have completed several updates reflecting Shelhamer's suggestions; I will merge these back into the PR branch momently; in the meantime please refer https://github.com/eelstork/caffe/tree/separate-io-update |
shelhamer
added the
focus
label
Sep 2, 2015
|
@shelhamer actioned all suggested changes; I would suggest keeping the test matrix as is since it doesn't appear to be slowing things down much and will help maintaining this feature. |
shelhamer
commented on an outdated diff
Sep 4, 2015
| * `protobuf`, `glog`, `gflags` | ||
| -* IO libraries `hdf5`, `leveldb`, `snappy`, `lmdb` | ||
| +* IO libraries `hdf5`, `leveldb`, `snappy`, `lmdb` (optional) |
shelhamer
Owner
|
shelhamer
commented on the diff
Sep 4, 2015
| @@ -1,5 +1,5 @@ | ||
| #!/bin/bash | ||
| -# Script called by Travis to do a CPU-only build of and test Caffe. | ||
| +# Script called by Travis to build and test Caffe. |
shelhamer
Owner
|
|
Thanks @eelstork! I made last comments on minor docs + comment changes so this looks good to me for merge once those are taken care of. Second opinions @longjon @jeffdonahue ? |
jeffdonahue
commented on an outdated diff
Sep 4, 2015
|
See above nit, otherwise mostly LGTM. I'd prefer if the
But that's minor and a lot of work to change; not really necessary IMO. |
|
@jeffdonahue @shelhamer What do you think of the related #2619? |
|
@shelhamer and @jeffdonahue thanks for these suggestions, I have made changes accordingly (see relevant commits); squash? |
|
@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. |
|
@shelhamer @jeffdonahue @bhack @Nerei, opinions about 58f017e ? |
|
@shelhamer - updated; squashed. |
|
@shelhamer Anything missing to get this merged? |
|
@eelstork I took another look -- sorry for the last minute comments. Otherwise looks good for merge to me. |
|
@jeffdonahue updated. I would suggest leaving 2349c6d as a separate commit. |
|
Thanks @eelstork! |
jeffdonahue
added a commit
that referenced
this pull request
Sep 17, 2015
|
|
jeffdonahue |
5ff3734
|
jeffdonahue
merged commit 5ff3734
into
BVLC:master
Sep 17, 2015
1 check passed
|
@jeffdonahue Can you take a look at related #2619? |
mtngld
commented on f3a933a
Sep 17, 2015
|
Hi, After pulling the latest from master, rebuilding and caffe train on my LMDB I was getting this error:
Turns out my old Makefile.config is not backward compatible with this PR ( Solved it easily by copying again the new Makefile.config.example to Makefile.config, and making my regular modifications. putting this comment here for anyone who might encounter the same issue. |
|
@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. |
|
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. |
This was referenced Sep 17, 2015
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. |
|
@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
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 |
|
@danst18 sorry for the late reply. I submitted a fix for this. Thank you for reporting the issue. |
eelstork commentedMay 28, 2015
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.