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

Clean up Boost dependencies in classification and detection programs #113

Open
psyhtest opened this issue Jul 3, 2017 · 4 comments
Open
Assignees

Comments

@psyhtest
Copy link
Member

psyhtest commented Jul 3, 2017

I've found several issues with the Boost dependencies in the Caffe classification and detection programs (caffe-classification, caffe-classification-cuda, caffe-classification-opencl, caffe-detection-ssd, caffe-detection-ssd-cuda).

  1. Boost is specified twice as follows:
    "boost": {
      "local": "yes",
      "name": "Boost C++ libraries",
      "skip_from_bat": "yes",
      "sort": 30,
      "tags": "lib,boost"
    },
...
    "lib-boost": {
      "force_add_static_lib_path": "yes",
      "local": "yes",
      "name": "Boost library",
      "sort": 13,
      "tags": "lib,boost"
    },

Apart from the obvious name difference, the first dependency specifies "skip_from_bat": "yes", while the second dependency specifies "force_add_static_lib_path": "yes". Removing the first dependency seems not to affect anything at compile or runtime on Linux. But I'm cautious not to commit this change until we understand possible implications on Windows and Android.

  1. With the lib-boost sort order of 13, using a non-system Boost installed via CK (e.g. ck install package:lib-boost-1.62.0) results in the following link warnings:
g++-5     classification.o  -o classification    -L/home/anton/CK_TOOLS/lib-caffe-bvlc-master-cpu-master-gcc-5.4.0-linux-64/install/lib -lcaffe  -L/home/anton/CK_TOOLS/lib-gflags-2.2.0-gcc-5.4.0-linux-64/install/lib -lgflags -L/usr/lib/x86_64-linux-gnu  -lglog  -L/home/anton/CK_TOOLS/lib-openblas-0.2.19-gcc-5.4.0-linux-64/install/lib -lopenblas  -L/home/anton/CK_TOOLS/lib-protobuf-host-3.1.0-linux-64/install/lib -lprotobuf  -L/usr/lib/x86_64-linux-gnu -lopencv_core -L/home/anton/CK_TOOLS/lib-boost-1.62.0-gcc-5.4.0-linux-64/install/lib  -L/home/anton/CK_TOOLS/lib-rtl-xopenme-0.3-gcc-5.4.0-linux-64/lib -lrtlxopenme   -lglog -lboost_thread -lboost_date_time -lboost_filesystem -lboost_system -lopencv_imgproc -lopencv_highgui -lopencv_core    -lm    
/usr/bin/ld: warning: libboost_system.so.1.62.0, needed by /home/anton/CK_TOOLS/lib-caffe-bvlc-master-cpu-master-gcc-5.4.0-linux-64/install/lib/libcaffe.so, may conflict with libboost_system.so.1.58.0
/usr/bin/ld: warning: libboost_thread.so.1.62.0, needed by /home/anton/CK_TOOLS/lib-caffe-bvlc-master-cpu-master-gcc-5.4.0-linux-64/install/lib/libcaffe.so, may conflict with libboost_thread.so.1.58.0
***************************************************************************************

and a runtime failure suggesting the conflict does happen:

  (run ...)
executing code ...
./tmp-SujpBs.sh: line 38: 10861 Aborted                 (core dumped) ./classification ${CK_CAFFE_MODEL_FILE} ${CK_CAFFE_MODEL_WEIGHTS} ../imagenet_mean.binaryproto ../synset_words.txt /home/anton/CK_REPOS/ctuning-datasets-min/dataset/image-jpeg-dnn-cropped-panda/cropped_panda.jpg > tmp-output1.tmp 2> tmp-output2.tmp

 (printing output files) 

    * tmp-output1.tmp

    * tmp-output2.tmp

      terminate called after throwing an instance of 'std::bad_alloc'
        what():  std::bad_alloc

Changing the sort order to 6 eliminates the warnings:

g++-5     classification.o  -o classification    -L/home/anton/CK_TOOLS/lib-caffe-bvlc-master-cpu-master-gcc-5.4.0-linux-64/install/lib -lcaffe  -L/home/anton/CK_TOOLS/lib-gflags-2.2.0-gcc-5.4.0-linux-64/install/lib -lgflags -L/home/anton/CK_TOOLS/lib-boost-1.62.0-gcc-5.4.0-linux-64/install/lib -L/usr/lib/x86_64-linux-gnu  -lglog  -L/home/anton/CK_TOOLS/lib-openblas-0.2.19-gcc-5.4.0-linux-64/install/lib -lopenblas  -L/home/anton/CK_TOOLS/lib-protobuf-host-3.1.0-linux-64/install/lib -lprotobuf  -L/usr/lib/x86_64-linux-gnu -lopencv_core  -L/home/anton/CK_TOOLS/lib-rtl-xopenme-0.3-gcc-5.4.0-linux-64/lib -lrtlxopenme   -lglog -lboost_thread -lboost_date_time -lboost_filesystem -lboost_system -lopencv_imgproc -lopencv_highgui -lopencv_core    -lm
***************************************************************************************

Interestingly, increasing the sort order past 6 produces the same warnings and failures. Now, the sort order of 7 given to lib-glog, so I suspect it is GLog that "mixes in" the system Boost 1.58.0.

Now, I am currently using the system GLog as well.

anton@diviniti:~/CK_REPOS/ck-caffe/program/caffe-classification$ ck show env --tags=lib,glog
Env UID:         Target OS:      Bits: Name:        Version:            Tags:

49231e5e41df8f74        linux-64    64 GLog library 0                   64bits,glog,host-os-linux-64,lib,target-os-linux-64,v0
anton@diviniti:~/CK_REPOS/ck-caffe/program/caffe-classification$ cat /home/anton/CK_REPOS/local/env/49231e5e41df8f74/env.sh 
#! /bin/bash
# CK generated script

if [ "$1" != "1" ]; then if [ "$CK_ENV_LIB_GLOG_SET" == "1" ]; then return; fi; fi

# Soft UOA           = lib.glog (d42a1422abbcbb6a)  (lib,glog,64bits,host-os-linux-64,target-os-linux-64,v0)
# Host OS UOA        = linux-64 (4258b5fe54828a50)
# Target OS UOA      = linux-64 (4258b5fe54828a50)
# Target OS bits     = 64
# Tool version       = 0
# Tool split version = [0]

export CK_ENV_LIB_GLOG_LIB=/usr/lib/x86_64-linux-gnu
export CK_ENV_LIB_GLOG_INCLUDE=/usr/include

export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu":$LD_LIBRARY_PATH
export LIBRARY_PATH="/usr/lib/x86_64-linux-gnu":$LIBRARY_PATH

export CK_ENV_LIB_GLOG=/usr
export CK_ENV_LIB_GLOG_DYNAMIC_NAME=libglog.so
export CK_ENV_LIB_GLOG_LFLAG=-lglog
export CK_ENV_LIB_GLOG_STATIC_NAME=libglog.a

export CK_ENV_LIB_GLOG_SET=1

Next, I'll try to install GLog via CK.

@psyhtest psyhtest changed the title lib-boost issues in classification programs lib-boost issues in classification and detection programs Jul 3, 2017
@psyhtest
Copy link
Member Author

psyhtest commented Jul 3, 2017

In fact, even if GLog is installed via CK (from trunk, although a stable package is wanted), the problem is the same.

@gfursin
Copy link
Contributor

gfursin commented Jul 3, 2017

There is an issue that I noticed some time ago and it's not fixed. When mixing automatically detected libs and installed via CK, a system path /usr/lib64 can be added to LD_LIBRARY_PATH in the middle and it mixes up linking (i.e. part of the libs will be from CK and part suddenly overloaded from /usr/lib64). There is no obvious solution and I found that other package managers/cmake complain about the same issue... One of the ideas is to avoid using LD_LIBRARY_PATH and always use full explicit paths, but not all native packages support that (cmake often tries to be smart)... That's why I had this ugly trick with adding boost twice ...

@psyhtest
Copy link
Member Author

psyhtest commented Jul 3, 2017

As I mentioned, boosting (sic:)) the order of:

    "lib-boost": {
      "force_add_static_lib_path": "yes",
      "local": "yes",
      "name": "Boost library",
      "sort": 13,
      "tags": "lib,boost"
    },

to 4, eliminated the link-time warnings and run-time failures.

Moreover, I could get rid of:

    "boost": {
      "local": "yes",
      "name": "Boost C++ libraries",
      "skip_from_bat": "yes",
      "sort": 30,
      "tags": "lib,boost"
    },

completely (at least on my Ubuntu laptop).

Is it still needed? If yes, I suggest we clean this across all the programs e.g. as follows:

    "lib-boost": {
      "force_add_static_lib_path": "yes",
      "local": "yes",
      "name": "Boost library",
      "sort": 4,
      "tags": "lib,boost"
    },
    "lib-boost2": {
      "local": "yes",
      "name": "Boost library (2)",
      "skip_from_bat": "yes",
      "sort": 400,
      "tags": "lib,boost"
    },

I'm also confused about the skip_from_bat and force_add_static_lib_path keys.

@psyhtest psyhtest changed the title lib-boost issues in classification and detection programs Clean up Boost dependencies in classification and detection programs Jul 18, 2017
@gfursin
Copy link
Contributor

gfursin commented Jul 18, 2017

Unfortunately, there are some nuances on some platforms, so I would suggest not to touch it now! The solution is to avoid using LD_LIBRARY_PATH with mixing CK-installed packages and usr/lib, but instead use only explicit paths ... But it's not done yet, and will require various changes in the CK ... I would prefer not to do it right now since we can break lots of deps ... But I am thinking one day to update handling of such vars in the CK when I have more time ...

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

No branches or pull requests

2 participants