Caffe: ImportError:caffe.so: undefined symbol: _ZN5caffe4mtx_E

Created on 17 Mar 2016  ·  9Comments  ·  Source: BVLC/caffe

Hi Caffe users,

I want to be able to use pycaffe, so I have built caffe using:

make all
make test
make runtest
make pycaffe

and everything runs smoothly, with 2 disabled tests.

However, error occurs when i try to import caffe in python console:

17:35 $ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/syq/surveillance_video/tools/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "/home/syq/surveillance_video/tools/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver
ImportError: /home/syq/surveillance_video/tools/caffe/python/caffe/_caffe.so: undefined symbol: _ZN5caffe4mtx_E

I am using Ubuntu 14.04 with Python 2.7.6, CUDA 7.0

This is what my PYTHONPATH looks like:
17:35 $ echo $PYTHONPATH
/home/syq/surveillance_video/tools/caffe/python:/home/syq/surveillance_video/tools/caffe/distribute/python:

Does anyone have a clue as to what _ZN5caffe4mtx_E is from?
Please offer any help! Thanks!

Most helpful comment

@xiw9 I had it uncommented, yet I'm still getting the same error!

All 9 comments

Makefile.config
Uncomment to support layers written in Python (will link against Python libs)
WITH_PYTHON_LAYER := 1

Thanks xiw9!
Uncommenting the line:
WITH_PYTHON_LAYER := 1
solved the problem! I can't believe I missed that.

@xiw9 I had it uncommented, yet I'm still getting the same error!

@xiw9 Thanks for your reply! I have solved this problem using your answer. That's so magical!

it compiled properly for python2.7
but when I change makefile.config to compile it for python3, I got the same error
I had it uncommented, but I'm still getting the same error

How did you fix it for python3 ? I still have the same error ...

it compiled properly for python2.7
but when I change makefile.config to compile it for python3, I got the same error
I had it uncommented, but I'm still getting the same error

Yes I am

@xiw9 I had it uncommented, yet I'm still getting the same error!
then,did you solve?

5810 Fixed it for me.

One thing to keep in mind is that you'll probably have to adjust the python3.x version for location and libraries in Makefile.config.

Was this page helpful?
0 / 5 - 0 ratings