Caffe: libcaffe.so.1.0.0-rc3 problem

Created on 25 Jan 2016  路  50Comments  路  Source: BVLC/caffe

is this a problem?
ImportError: dlopen(caffe/_caffe.so, 2): Library not loaded: libcaffe.so.1.0.0-rc3

build

Most helpful comment

On CentOS, I fixed the missing libcaffe error by adding /path/to/caffe/lib/ to LD_LIBRARY_PATH in .bash_profile file by adding this line:
export LD_LIBRARY_PATH=/path/to/caffe/lib/:$LD_LIBRARY_PATH

All 50 comments

This is a dlopen on python/caffe/_caffe.so, correct? And I'm assuming you built with Make instead of CMake?

Looks to me like Make links python/caffe/_caffe.so to build/lib/libcaffe.so correctly:

$ ldd python/caffe/_caffe.so  | grep caf
    libcaffe.so.1.0.0-rc3 => /home/lyeager/caffe/caffe/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3 (0x00007fa439e55000)

How did you come up with that error?

@lukeyeager ,thank you for reply.
does it work only using cmake?

I replied because I thought your problem might be related to my recent changes at https://github.com/BVLC/caffe/pull/3311. I can't tell if your issue actually has anything to do with those changes unless you can give me some steps to reproduce the error that you reported.

And no, my changes should work with either Make or CMake. I just asked because I wondered if you might be on some platform other than Ubuntu 14.04. CMake tends to handle multi-platform builds better than the raw Makefile build.

I am facing this libcaffe.so.1.0.0-rc3 problem

I just downloaded the recent git...and trying to make it includes some FastRcnn staff..so in my Makefile.config I have line WITH_PYTHON_LAYER := 1

library compiles and my project link with it...but when comes to running, I got error
error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory

Can you give me some more information?

  • Did you build with Make or CMake?
  • When you say "running" what do you mean? Can you paste the command you tried and the exact error that it returned?
  • What do these commands return?
$ python -c 'import platform; print platform.platform()'
Linux-3.13.0-76-generic-x86_64-with-Ubuntu-14.04-trusty

$ ldd build/tools/caffe | grep caffe
    libcaffe.so.1.0.0-rc3 => /home/lyeager/caffe/caffe/build/tools/../lib/libcaffe.so.1.0.0-rc3 (0x00007fe4bb78b000)

$ ldd python/caffe/_caffe.so | grep caffe
    libcaffe.so.1.0.0-rc3 => /home/lyeager/caffe/caffe/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3 (0x00007f6d0d4d1000)
  • make command for following config: http://justpaste.it/qwka
  • I have my own c++ project that links against libcaffe.so. When try to run my executable it gives above error. It is just executable running. Although it complaints about this library name, it actually exists and generated in build/lib. I added the path to my LD_LIBRARY_PATH as usual.

For commands:

$ python -c 'import platform; print platform.platform()'
Linux-2.6.32-573.12.1.el6.x86_64-x86_64-with-centos-6.7-Final
$ ldd build/tools/caffe | grep caffe
libcaffe.so.1.0.0-rc3 => /cs/vml2/msibrahi/workspaces/caffe_20160126/build/tools/../lib/libcaffe.so.1.0.0-rc3 (0x00007fd36230c000)
$ ldd python/caffe/_caffe.so | grep caffe
libcaffe.so.1.0.0-rc3 => /cs/vml2/msibrahi/workspaces/caffe_20160126/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3 (0x00007f3b472bd000)

@mostafa-saad I'm not seeing anything obvious that you're doing wrong. Nor can I see anything in https://github.com/BVLC/caffe/pull/3311 that looks problematic. All the tools and examples build against libcaffe.so and they seem to be linking just fine.

It seems most likely that you have some sort of issue with your project's build/link setup. Otherwise I guess maybe this is a CentOS vs. Ubuntu thing? I don't have a way to test on your platform.

Not sure. I was building and using some caffe versions in 2015, and was totally ok.

I am not sure why in this time, the file libcaffe.so.1.0.0-rc3 is generated. Usually, it was not generated. I will dig more at some time and see. I may also try it on my personal ubuntu. This is my reserach lab machine.

I met the same problem. I am using OS X 10.11.3 and zsh. When I ran make runtest,

.build_release/tools/caffe
dyld: Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /Users/liboyue/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5

my DYLD_LIBRARY_PATH is

/Users/liboyue/caffe/build/lib:/Users/liboyue/caffe/.build_release/lib

Someone faced the same issue too.

Thanks for the bug report @liboyue. I've got two short-term solutions for you:

  1. You can go back to a97300c85a0e2171c2f5744877a1682cd467ae79 (the last commit before #3311 was merged)
  2. You could try building with CMake instead of Make

I'll try to find an OSX machine to test this on, but I could use some help if somebody with knowledge about building on OSX wants to chime in!

I found an old Mac (OSX 10.10.4) to test this on and didn't have any problems with either build system.

# Check platform
$ python -c 'import platform; print platform.platform'
Darwin-14.4.0-x86_64-i386-64bit

# Makefile build
$ make all runtest
$ build/tools/caffe --version
caffe version 1.0.0-rc3

# CMake build
$ mkdir build && cd build
$ cmake .. -DCPU_ONLY=On
$ make all runtest
$ tools/caffe --version
caffe version 1.0.0-rc3

That may not help anyone on this thread, but I'm glad to know that not ALL Mac builds are broken, at least.

It might be worth checking that your binary is built with the proper links:

# Makefile build
$ otools -L buildtools/caffe | grep caffe
    libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)

# CMake build
$ otools -L tools/caffe | grep caffe
    @rpath/libcaffe.1.0.0-rc3.dylib (compatibility version 1.0.0, current version 1.0.0)

I would like to apologize, Things are ok on both Centos and Ubuntu 14. It was a mistake from my side in my DYLD_LIBRARY_PATH :(

Kindly ignore all my posts

@lukeyeager I don't konw how to use cmake...

[  1%] Built target proto
[  1%] Building CXX object src/caffe/CMakeFiles/caffe.dir/blob.cpp.o
In file included from /Users/liboyue/caffe/src/caffe/blob.cpp:7:
In file included from /Users/liboyue/caffe/include/caffe/util/math_functions.hpp:11:
/Users/liboyue/caffe/include/caffe/util/mkl_alternate.hpp:11:10: fatal error: 'cblas.h' file not found
#include <cblas.h>
         ^
1 error generated.
make[2]: *** [src/caffe/CMakeFiles/caffe.dir/blob.cpp.o] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
make: *** [all] Error 2

But this commit https://github.com/BVLC/caffe/commit/a97300c85a0e2171c2f5744877a1682cd467ae79 works fine on my Mac.

Thanks a lot : )

I also met the exact problem as mentioned by @liboyue on OSX 10.11.2. Reverting to the old commit a97300c fixed it. Thanks for the workaround @lukeyeager!

I am facing such kind of a problem:

Traceback (most recent call last): File "art.py", line 13, in <module> import caffe File "/home/erreth_akbe/python/caffe/__init__.py", line 1, in <module> from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver File "/home/erreth_akbe/python/caffe/pycaffe.py", line 13, in <module> from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory

Help much appreciated

I am facing the exact same issue.

git clone: ok
cd caffe: ok.

But:

$ make all
...
CXX ...: ok
*some warnings*
...
LD .build_release/src/caffe/test/test_util_blas.o
.build_release/tools/caffe
dyld: Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /Users/me/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5

And then:

$make test
make: Nothing to be done for `test'.

And finally:

$ make runtest
.build_release/tools/caffe
dyld: Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /Users/me/caffe/.build_release/tools/caffe
  Reason: image not found
make: *** [runtest] Trace/BPT trap: 5

I am using mac os x 10.10.5.

I'm not sure how the linking bug was introduced, but running the following two lines after make all and make test fixes the problem for good:
install_name_tool -change libcaffe.so.1.0.0-rc3 @executable_path/../lib/libcaffe.so.1.0.0-rc3 .build_release/tools/caffe
install_name_tool -change libcaffe.so.1.0.0-rc3 @executable_path/../lib/libcaffe.so.1.0.0-rc3 .build_release/test/test_all.testbin

And if using pycaffe:
install_name_tool -change libcaffe.so.1.0.0-rc3 @loader_path/../../.build_release/lib/libcaffe.so.1.0.0-rc3 python/caffe/_caffe.so

I should clarify that the above fix is only of OSX and it simply changes the library path inside the binary to point to the relative path (rather than expecting it to be in the system path).

I encountered the same issue on Ubuntu 14.04.

Ran

make all
make test
make run test
...
[----------] Global test environment tear-down
[==========] 1019 tests from 144 test cases ran. (34669 ms total)
[  PASSED  ] 1019 tests.

make pycaffe
make distribute

then tried to import caffe on IPython, the error message was shown as below:

In [8]: sys.path.insert(0, "/usr/local/caffe/distribute/python/caffe")

In [9]: import caffe
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-9-1cca3aa1f8c5> in <module>()
----> 1 import caffe

/home/vagrant/pycaffe/caffe/__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
      2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
      3 from ._caffe import __version__
      4 from .proto.caffe_pb2 import TRAIN, TEST
      5 from .classifier import Classifier

/home/vagrant/pycaffe/caffe/pycaffe.py in <module>()
     11 import numpy as np
     12
---> 13 from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
     14         RMSPropSolver, AdaDeltaSolver, AdamSolver
     15 import caffe.io

ImportError: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory

@KellyChan what happens if you try to import forom caffe/python instead of caffe/distribute/python?

@lukeyeager, thanks for your reply.

If I tried to

  • import caffe from /usr/local/caffe/python/caffe on Anaconda, it was shown that google.protobuf is missing.
  • then conda install protobuf, it did not work.

Alternatively, I changed to test by script:

  • created a file called test.py
  • type sudo python test.py, it was shown another error: libdc1394 error: Failed to initialize libdc1394

test.py

import matplotlib
matplotlib.use('Agg')

import sys
sys.path.insert(0, '/usr/local/caffe/python/')
import caffe

@KellyChan protobuf dependencies are definitely not related to this issue. Please read the Python installation instructions and ask for help in the caffe-users list if you still need it.

@lukeyeager Thanks for your reference links.

Just would like to provide some feedback.

If I set up the imported libraries in python scripts, everything worked well. I could run the model.

import matplotlib
matplotlib.use('Agg')

import sys
sys.path.insert(0, '/usr/local/caffe/python/')
import caffe

If I imported caffe/python on IPython/IPython Notebook directly, the error message was shown as below. What I am curious is import matplotlib matplotlib.use('Agg') worked for python scripts, but it could not work for IPython/IPython Notebook.

from cStringIO import StringIO
import numpy as np
import scipy.ndimage as nd
import PIL.Image
from IPython.display import clear_output, Image, display
from google.protobuf import text_format

import caffe
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-9-c7a7d75957cd> in <module>()
      6 from google.protobuf import text_format
      7 
----> 8 import caffe

/usr/local/caffe/python/caffe/__init__.py in <module>()
----> 1 from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
      2 from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
      3 from ._caffe import __version__
      4 from .proto.caffe_pb2 import TRAIN, TEST
      5 from .classifier import Classifier

/usr/local/caffe/python/caffe/pycaffe.py in <module>()
     13 from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
     14         RMSPropSolver, AdaDeltaSolver, AdamSolver
---> 15 import caffe.io
     16 
     17 # We directly update methods from Net here (rather than using composition or

/usr/local/caffe/python/caffe/io.py in <module>()
      1 import numpy as np
----> 2 import skimage.io
      3 from scipy.ndimage import zoom
      4 from skimage.transform import resize
      5 

/usr/local/lib/python2.7/dist-packages/skimage/io/__init__.py in <module>()
     13 
     14 
---> 15 reset_plugins()
     16 
     17 WRAP_LEN = 73

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in reset_plugins()
     87 def reset_plugins():
     88     _clear_plugins()
---> 89     _load_preferred_plugins()
     90 
     91 

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in _load_preferred_plugins()
     67     io_types = ['imsave', 'imshow', 'imread_collection', 'imread']
     68     for p_type in io_types:
---> 69         _set_plugin(p_type, preferred_plugins['all'])
     70 
     71     plugin_types = (p for p in preferred_plugins.keys() if p != 'all')

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in _set_plugin(plugin_type, plugin_list)
     79             continue
     80         try:
---> 81             use_plugin(plugin, kind=plugin_type)
     82             break
     83         except (ImportError, RuntimeError, OSError):

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in use_plugin(name, kind)
    249             kind = [kind]
    250 
--> 251     _load(name)
    252 
    253     for k in kind:

/usr/local/lib/python2.7/dist-packages/skimage/io/manage_plugins.pyc in _load(plugin)
    293         modname = plugin_module_name[plugin]
    294         plugin_module = __import__('skimage.io._plugins.' + modname,
--> 295                                    fromlist=[modname])
    296 
    297     provides = plugin_provides[plugin]

/usr/local/lib/python2.7/dist-packages/skimage/io/_plugins/matplotlib_plugin.py in <module>()
      2 import numpy as np
      3 import warnings
----> 4 import matplotlib.pyplot as plt
      5 from ...util import dtype as dtypes
      6 from ...exposure import is_low_contrast

/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py in <module>()
    112 
    113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    115 
    116 _IP_REGISTERED = None

/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.pyc in pylab_setup()
     30     # imports. 0 means only perform absolute imports.
     31     backend_mod = __import__(backend_name,
---> 32                              globals(),locals(),[backend_name],0)
     33 
     34     # Things we pull in from all backends

/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3agg.py in <module>()
      9 
     10 from . import backend_agg
---> 11 from . import backend_gtk3
     12 from .backend_cairo import cairo, HAS_CAIRO_CFFI
     13 from matplotlib.figure import Figure

/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py in <module>()
     56 
     57 cursord = {
---> 58     cursors.MOVE          : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
     59     cursors.HAND          : Gdk.Cursor.new(Gdk.CursorType.HAND2),
     60     cursors.POINTER       : Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR),

TypeError: constructor returned NULL

@safrooze when i try to modify the pycaffe lib i get:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: changing install names or rpaths can't be redone for: python/caffe/_caffe.so (for architecture x86_64) because larger updated load commands do not fit (the program must be relinked, and you may need to use -headerpad or -headerpad_max_install_names)

my temporary workaround is to copy libcaffe.so.1.0.0-rc3 to whatever directory i'm working from.

@kylemcdonald that's strange as the install names should be pretty much the same between mine and yours if you're building the latest caffe. What's the output of "otool -L python/caffe/_caffe.so"? Also, to be sure this is just a name-length issue, you can copy libcaffe.so.1.0.0-rc3 to /usr/libs (can even rename it to libcaffe.so) and provide this much shorter path to isntall_name_tool and see if that solves it. If it does, then somehow your library paths must be longer than mine and the small change doesn't fit.

after further work on this, it turns out that there were other problems with my libcaffe.so, even though it didn't give any errors on import caffe it gave errors when i tried to actually call any functions. so i'm not sure i'm qualified to comment on what is & isn't working :)

From https://github.com/BVLC/caffe/issues/3628
It solves my (this) problem.

This issue manifests in OS X 10.11 since it disregards the DYLD_* environment variables. The cause is that the Makefile's install name configuration of the library on OS X was broken in #3311.

3696 fixes the Makefile. Please follow-up if there is a CMake issue.

@safrooze thanks for pointing out the precise issue and a linking fix in https://github.com/BVLC/caffe/issues/3597#issuecomment-178898935.

@kylemcdonald try #3696.

@mostafa-saad I met similar issue:
error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory
how did you fixed this problem?
Thanks.

Fixed in Makefile by #3696.

I had the same problem (and I spent too much time to solve it, but I did!!).

Using the ldd command on /home/me/mylibs/caffe/distribute/python/ I got this:

ldd ./caffe/_caffe.so
linux-vdso.so.1 =>  (0x00007ffd56b36000)
libcaffe.so.1.0.0-rc3 => not found
libglog.so.0 => /usr/lib/x86_64-linux-gnu/libglog.

...

but executing it in /home/me/mylibs/caffe/python/ got this:

ldd ./caffe/_caffe.so
linux-vdso.so.1 =>  (0x00007ffca1e7a000)
libcaffe.so.1.0.0-rc3 => /home/me/mylibs/caffe/python/./caffe/../../build/lib/libcaffe.so.1.0.0-rc3 (0x00007f57e6923000)
libglog.so.0 => /usr/lib/x86_64-linux-gnu/libglog.so.0 (0x00007f57e66eb000)
...

hence I change my PYTHONPATH to this:
export PYTHONPATH=/home/me/mylibs/caffe/python
(just added to the bottom of .bashrc and source it)

It worked!!!!

P.D.: sure there is a more ellegant way to fix it, but... now I can continue my work.

I fixed this issue by adding /path/to/caffe/distribute/lib to LD_LIBRARY_PATH, hope that helps anybody!

On CentOS, I fixed the missing libcaffe error by adding /path/to/caffe/lib/ to LD_LIBRARY_PATH in .bash_profile file by adding this line:
export LD_LIBRARY_PATH=/path/to/caffe/lib/:$LD_LIBRARY_PATH

@lukeyeager hi, I meet the same error and when I do:
otool -L python/caffe/_caffe.so
the result is
python/caffe/_caffe.so (compatibility version 0.0.0, current version 0.0.0)
@rpath/libcaffe.so.1.0.0-rc3 (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libglog.0.dylib (compatibility version 1.0.0, current version 1.0.0)
it seems that _caffe.so link the wrong path of libcaffe.so.1.0.0-rc3

Do you get any solution?

@TimingSpace OS X 10.11 introduced restrictions on relative rpath usage. Use install_name_tool to add an absolute rpath.

For instance, when I ran otool -l -v /usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so:

...
Load command 10
          cmd LC_LOAD_DYLIB
      cmdsize 48
         name libcaffe.so.1.0.0-rc3 (offset 24)
   time stamp 2 Wed Dec 31 16:00:02 1969
      current version 0.0.0
compatibility version 0.0.0
...

As we see, libcaffe.so.1.0.0-rc3 has no path specified and hence falls back on the relative rpath that's restricted in OS X 10.11:

ImportError: dlopen(/usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so, 2): Library not loaded: libcaffe.so.1.0.0-rc3
  Referenced from: /usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so
  Reason: unsafe use of relative rpath libcaffe.so.1.0.0-rc3 in /usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so with restricted binary

So I made it absolute and it fixed the issue:

install_name_tool -change libcaffe.so.1.0.0-rc3 @rpath/libcaffe.so.1.0.0-rc3 /usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so
install_name_tool -add_rpath /usr/local/lib /usr/local/stow/caffe-1.0.0-rc3/python/caffe/_caffe.so

@lukeyeager i met the same quesion above. I tried the tips from yours. I got the following messages:
$ python -c 'import platform; print platform.platform()'
Linux-3.13.0-100-generic-x86_64-with-debian-jessie-sid
$ ldd build/tools/caffe | grep caffe
libcaffe.so.1.0.0-rc3 => /home/ubuntu/Downloads/caffe-master/build/tools/../lib/libcaffe.so.1.0.0-rc3(0x000007f171e490000)
$ ldd python/caffe/_caffe.so | grep caffe
ldd: python/caffe/_caffe.so:No such file or directory

can you give me some tips?
Besides, the system i am used is ubuntu 14.04LTS, is different to the answer from the first order.

I'm having the same problem: Ubuntu 16.04 and with C++ API

`#include

include

include

include

include

include

include

include "caffe/util/signal_handler.h"

include

include

include

include

include

include

include "boost/algorithm/string.hpp"

using caffe::Blob;
using caffe::Caffe;
using caffe::Net;
using caffe::Layer;
using caffe::Solver;
using caffe::shared_ptr;

int main() {
// generate 400 sets of training data. Each training data has the batch size of 64
float data = new float[64113400];
float *label = new float[64
111*400];

for(int i = 0; i<6411400; ++i)
{
int a = rand() % 2;
int b = rand() % 2;
int c = a ^ b;
data[i
2 + 0] = a;
data[i*2 + 1] = b;
label[i] = c;
}

// Create a solver parameter object and load solver.prototxt into it
caffe::SolverParameter solver_param;
return 0;
}
`

caffeCppAPIExample$ make
g++ -Wno-unused-result -O3 -std=c++11 -I /home/marco/caffe-master/build/install/include -I /opt/disco_vecchio/usr/local/cuda-7.5/targets/x86_64-linux/include -L /home/marco/caffe-master/build/install/lib caffeCppAPIExample.cpp -lcaffe -lglog -lboost_system -ocaffeCppAPIExample

./caffeCppAPIExample
./caffeCppAPIExample: error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: No such file or directory

What to do to solve the problem?
Looking forward to your helpfull hints.
Marco

I temporary "solved" by this:
export LD_LIBRARY_PATH=/home/marco/caffe-master/build/install/lib
But actually I do not like this temporary solution at all...
Are there any better, long-lasting solutions?
Marco

@lukeyeager : I have installed caffe on Ubuntu16.04 via CMAKE without any errors and I think successfully. Now I want to import caffe in python and I can not. I had GLIBCXX version problem in which the new version did not exist in anaconda2 but I brought that using Ubuntu library. Now when importing caffe I have another error which I have not found any solutions or same problems!

here is the error:

>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/caffe-master/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, ``AdaDeltaSolver, AdamSolver
File "/home/user/caffe-master/python/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: /home/user/caffe-master/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3: undefinedsymbol: _ZN2cv8imencodeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArra ERSt6vectorIhSaIhEERKSB_IiSaIiEE`

and here are my results for some items you had asked above:

user:~$ python -c 'import platform; print platform.platform()'
Linux-4.4.0-53-generic-x86_64-with-debian-stretch-sid

user:~/caffe-master$ ldd build/tools/caffe | grep caffe
libcaffe.so.1.0.0-rc3 => /home/user/caffe-master/build/tools/../lib/libcaffe.so.1.0.0-rc3 (0x00007f1a1ee0e000)

user:~/caffe-master$ ldd python/caffe/_caffe.so | grep caffe
libcaffe.so.1.0.0-rc3 => /home/user/caffe-master/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3 (0x00007fcfa4783000)

I have also included caffe in bashrc as:

export PATH="/home/user/anaconda2/bin:/home/user/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$PATH"
export PYTHONPATH="/home/user/caffe-master/python:$PYTHONPATH"
export LD_LIBRARY_PATH="/home/user/caffe-master/distribute/lib:$LD_LIBRARY_PATH"
export CAFFE_HOME="/home/user/caffe-master/lib:$CAFFE_HOME"

I really don't know what else I can do. Can you help me?

Add -Wl,-rpath,<path-to-caffe>/build/lib in your Makefile or flags when you compile

I tried the above and still got this

ImportError: /home/archpengown/Downloads/intel-caffe/.build_release/lib/libcaffe.so.1.0.0-rc3: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev

@Daenerys24 Have you solved this problem? I have the same problem as you.
Using Ubuntu 16.04.2, Matlab R2016b & R2014b

@jinyu121 Have you solved this problem? I have the same problem as you when I install protobuf 3.2. Using Ubuntu 16.04.4 Matlab R2014a gcc 5.4.0

@AemikaChow Yeah, I solved this problem.
The .so file is toooooo old in MATLAB, even in R2016b. So we just replace it(make a soft link).

In my case:

  • libstdc++.so.6: version 'GLIBCXX_3.4.21' not found: ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2016b/bin/glnxa64/libstdc++.so.6
  • _ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev: Please use a older version of protobuf, maybe 2.5.0 is okay. I forget how i handle this problem.
  • _ZN2cv6imreadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi:
$ sudo ln -sf /usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4 /usr/local/MATLAB/R2014a/bin/glnxa64/libopencv_core.so.2.4
$ sudo ln -sf /usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4 /usr/local/MATLAB/R2014a/bin/glnxa64/libopencv_highgui.so.2.4
$ sudo ln -sf /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.2.4 /usr/local/MATLAB/R2014a/bin/glnxa64/libopencv_imgproc.so.2.4
$ sudo ln -sf /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /usr/local/MATLAB/R2014a/bin/glnxa64/libfreetype.so.6

Maybe _ZNK6google... can be solve using softlink.

ref: #3934 #5447

@thinkski thanks! I use macOS 10.12.4, and I encounter the same problem like this:

Python 2.7.10 (default, Feb  6 2017, 23:53:20)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/myid/work/caffe/caffe/distribute/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/Users/myid/work/caffe/caffe/distribute/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: dlopen(/Users/myid/work/caffe/caffe/distribute/python/caffe/_caffe.so, 2): Library not loaded: @rpath/libcaffe.so.1.0.0
  Referenced from: /Users/myid/work/caffe/caffe/distribute/python/caffe/_caffe.so
  Reason: image not found

and, otool looks like this

otool -l -v distribute/python/caffe/_caffe.so | grep caf
distribute/python/caffe/_caffe.so:
         name python/caffe/_caffe.so (offset 24)
         name @rpath/libcaffe.so.1.0.0 (offset 24)

I thought the @rpath might not right, and I set like this,

install_name_tool -add_rpath /Users/myid/work/caffe/caffe/distribute/lib /Users/myid/work/caffe/caffe/distribute/python/caffe/_caffe.so

It works.

For anyone having the error in macOS 10.12.5:

Library not loaded: libcaffe.so.1.0.0-rc3

Check if you have the library libcaffe.so.1.0.0-rc3 under /usr/local/lib. If not copy it into that directory and rerun.

@thinkski
Thanks for your perfect solution! I used it to solve another issue here. https://github.com/rbgirshick/py-faster-rcnn/issues/634

If someone else bump into things like:

ImportError: dlopen($YOUR_DIR/py-faster-rcnn/caffe-fast-rcnn/python/caffe/_caffe.so, 2): Library not loaded: libcaffe.so.1.0.0-rc3
Reason: image not found

the link above can solve your question.

My error is not exactly as mentioned before: "libcaffe.so.1.0.0: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev", my error came from the libcaffe.so.1.0.0, not libcaffe.so.1.0.0-rc3. And what is the effective solution to solve this issue? I googled it and got one possible solution like this: http://hwengineer.blogspot.com/2017/07/&prev=search.

this helps me : https://groups.google.com/forum/#!topic/caffe-users/EA7zR-xhHoA

Was this page helpful?
0 / 5 - 0 ratings