Caffe, Python 3 and boost.python

4,777 views
Skip to first unread message

Waylon Flinn

unread,
Mar 28, 2015, 9:08:21 AM3/28/15
to caffe...@googlegroups.com
I'm attempting to do model inspection and classification on ImageNet using the classification notebook in iPython running in a Python 3.4 virtual env.

When running the first cell, I get an import error on the line for

import caffe

the error is:

ImportError: ../python/caffe/_caffe.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE


The rest of caffe seems to be installed correctly (I successfully trained a model). 
The problem seems to be with boost.python. Running the following command:

ldd ./python/caffe/_caffe.so | grep boost

yields:

libboost_python-py27.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0

In the same directory I also have:

/usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.54.0


My question is: 
How do I get caffe to use the 3.4 boost library instead of 2.7?

I see some work was done on this in this commit (it's also where the installation instructions were changed to say "Python 3.3+ should work out of the box")



Neeraj Goel

unread,
Apr 23, 2015, 4:27:47 AM4/23/15
to caffe...@googlegroups.com
I am encountering the same issue. Were you able to solve the problem? 

Ryan Carey

unread,
May 21, 2015, 7:26:32 AM5/21/15
to caffe...@googlegroups.com
I had the same problem and managed it by just switching back to Python 2 Caffe.

jussi...@gmail.com

unread,
Jul 3, 2015, 9:10:37 AM7/3/15
to caffe...@googlegroups.com
Same problem. Would also like to know the solution for this.

Paul F-Y

unread,
Sep 2, 2015, 11:13:11 AM9/2/15
to Caffe Users
The solution to this problem seems to be to go into the Makefile and replace boost_python with boost_python3 and python2.7 with python3.4m (or whatever version of python you're using) on the PYTHON_LIBRARIES line.

Everett Berry

unread,
Jun 14, 2016, 5:47:59 PM6/14/16
to Caffe Users
For those coming across this issue now... On my machine (Ubuntu 14.04) libboost_python3 simply wasn't symlinked in /usr/lib/x86_64-linux-gnu. To fix this I ran 
sudo ln -s /usr/lib/x86_64-linux-gnu/libboost_python-py34.so /usr/lib/x86_64-linux-gnu/libboost_python3.so
Reply all
Reply to author
Forward
0 new messages