Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caffe Compilation Error: gflags.cc' is being linked both statically and dynamically into this executable

I am trying to install caffe following this tutorial

Basically I have the following error when I type the last make command:

me@dl-01:/home/me/caffe-master$ make runtest

.build_release/tools/caffe

caffe: command line brew

usage: caffe command args

commands:

train           train or finetune a model

test            score a model

device_query    show GPU diagnostic information

time            benchmark model execution time

Flags from tools/caffe.cpp:
 -gpu (Run in GPU mode on given device ID.) type: int32 default: -1
 -iterations (The number of iterations to run.) type: int32 default: 50
 -model (The model definition protocol buffer text file..) type: string
      default: ""
 -snapshot (Optional; the snapshot solver state to resume training.)
 type: string default: ""
 -solver (The solver definition protocol buffer text file.) type: string
 default: ""
 -weights (Optional; the pretrained weights to initialize finetuning. Cannot
      be set simultaneously with snapshot.) type: string default: ""
.build_release/test/test_all.testbin 0 --gtest_shuffle 
ERROR: something wrong with flag 'flagfile' in file '/root/glog-0.3.3/gflags-master/src/gflags.cc'.  One possibility: file '/root/glog-0.3.3/gflags-master/src/gflags.cc' is being linked both statically and dynamically into this executable.
make: *** [runtest] Error 1

I don't understand how to solve this error. Did anybody find this error before? how can I solve it?

like image 297
mad Avatar asked Dec 10 '22 23:12

mad


1 Answers

Whether or not you've already solved this somewhere else, I'm posting the answer here in-case others run into the same problem.

Primarily, this problem seems to have come about because we don't always read things properly and blindly follow all instructions thinking they all apply to our case. hint: they don't.

In the installation instructions for Caffe (presuming Ubuntu instructions), there is a section which states:

Everything is packaged in 14.04.

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev protobuf-compiler

Blindly ignoring the next title, which states clearly:

Remaining dependencies, 12.04

we go on to install these dependencies, building and installing as required, resulting in the unfortunate side-effect of having 2 versions of libgflags, one dynamic (in /usr/lib[/x86_x64] and one static in /usr/local/lib

Resolution

  1. Promise ourselves failthfully we'll read instructions properly next time around.

  2. Uninstall libgflags

    sudo apt-get remove -y libgflags
    
  3. Delete make install versions

    sudo rm -f /usr/local/lib/libgflags.a /usr/local/lib/libgflags_nothreads.a
    sudo rm -rf  /usr/local/include/gflags
    
  4. Clean Caffe build

    cd <path>/<to>/caffe
    make clean
    
  5. Re-install libgflags package

    sudo apt-get install -y libgflags-dev
    
  6. Rebuild Caffe

    make all
    make test
    make runtest
    

Et Voila. All tests should now run and you're ready to rock the deep-learning boat.

like image 193
mproffitt Avatar answered Jan 21 '23 19:01

mproffitt