如何在Ubuntu中为python3安装caffe

nsk*_*nsl 3 python python-3.x caffe pycaffe

我在caffe上按照步骤操作,并更改了配置文件:

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/
Run Code Online (Sandbox Code Playgroud)

然后做了:

make all
make test
make runtest
Run Code Online (Sandbox Code Playgroud)

这些运行正常。但是当我跑步时:

make pycaffe
Run Code Online (Sandbox Code Playgroud)

我收到一个错误:

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
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

小智 6

可能您必须链接到其他python_boost版本。

在Makefile中找到以下行:

PYTHON_LIBRARIES ?= boost_python....
Run Code Online (Sandbox Code Playgroud)

可能您必须将其更改为boost_python-py35

PYTHON_LIBRARIES ?= boost_python-py35 python3.5m
Run Code Online (Sandbox Code Playgroud)

在/ usr / lib / x86_64-linux-gnu中查找libboost_python文件或您的lib所在的位置:

find /usr/lib/x86_64-linux-gnu/ -name libboost_python*so
find /usr/lib/x86_64-linux-gnu/ -name libpython*so
Run Code Online (Sandbox Code Playgroud)

将显示您可以选择的库。(如果文件是libboost_python-py35.so,则写boost_python-py35)boost和python库必须在版本上匹配。