nsknsl
nsknsl

Reputation: 147

How to install caffe for python3 in ubuntu

I followed the steps on caffe and changed the configure file:

PYTHON_LIBRARIES := boost_python3 python3.5m PYTHON_INCLUDE :=
/usr/include/python3.5m \
                /usr/lib/python2.7/dist-packages/numpy/core/include"

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include 
/usr/include/hdf5/serial/ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib
/usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/

Then did:

make all
make test
make runtest

These run OK. But when I run:

make pycaffe

I get an error:

CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp

/usr/bin/ld: cannot find -lboost_python3

collect2: error: ld returned 1 exit status Makefile:507: recipe for
target 'python/caffe/_caffe.so' failed make: ***
[python/caffe/_caffe.so] Error 1

How can I solve this problem?

Upvotes: 3

Views: 5303

Answers (3)

HARSH NILESH PATHAK
HARSH NILESH PATHAK

Reputation: 101

All these libs should already have been configured in your Make.config file

$ sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
$ sudo apt-get install -y python-numpy python-scipy
$ sudo apt-get install -y python3-dev
$ sudo apt-get install -y python3-numpy python3-scipy
$ sudo apt-get install -y libopencv-dev
$ sudo apt-get install libboost-all-dev 
$ apt-cache search gflags
$ sudo apt-get install libgflags2 libgflags-dev
$ sudo apt-get install libgflags libgflags-dev
$ sudo apt-get install libgflags-dev
$ sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
$ apt-cache search openblas
$ sudo apt-get install libopenblas-dev

Also refer:
1. https://gist.github.com/arundasan91/b432cb011d1c45b65222d0fac5f9232c
2. https://askubuntu.com/questions/629654/building-caffe-failed-to-see-hdf5-h
3. https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213

Upvotes: 1

Mykola Hrin
Mykola Hrin

Reputation: 11

Linker looks for libboost_python3, but in different systems this lib can have different names, i.e. ubuntu 16.04 have boost_python-py35 so you may create symlink

Upvotes: 1

Maurice Frank
Maurice Frank

Reputation: 86

Probably you have to link against a different python_boost version.

In the Makefile find the line:

PYTHON_LIBRARIES ?= boost_python....

Probably you have to change that to boost_python-py35:

PYTHON_LIBRARIES ?= boost_python-py35 python3.5m

Look in /usr/lib/x86_64-linux-gnu for the libboost_python files or wherever your libs are located:

find /usr/lib/x86_64-linux-gnu/ -name libboost_python*so
find /usr/lib/x86_64-linux-gnu/ -name libpython*so

will show you the libraries you can choose from. (If file is libboost_python-py35.so write boost_python-py35) The boost and python libs have to match in version.

Upvotes: 6

Related Questions