简体   繁体   English

如何在ubuntu中安装python3的caffe

[英]How to install caffe for python3 in ubuntu

I followed the steps on caffe and changed the configure file: 我按照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/

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? 我怎么解决这个问题?

Probably you have to link against a different python_boost version. 可能你必须链接到不同的python_boost版本。

In the Makefile find the line: 在Makefile中找到该行:

PYTHON_LIBRARIES ?= boost_python....

Probably you have to change that to boost_python-py35 : 可能你必须将其更改为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: 在/ usr / lib / x86_64-linux-gnu中查找libboost_python文件或libs所在的位置:

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. (如果文件是libboost_python-py35.so写boost_python-py35)boost和python库必须匹配版本。

链接器查找libboost_python3,但在不同的系统中,这个lib可以有不同的名称,即ubuntu 16.04有boost_python-py35所以你可以创建符号链接

All these libs should already have been configured in your Make.config file 应该已经在Make.config文件中配置了所有这些库

$ 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 1. https://gist.github.com/arundasan91/b432cb011d1c45b65222d0fac5f9232c
2. https://askubuntu.com/questions/629654/building-caffe-failed-to-see-hdf5-h 2. https://askubuntu.com/questions/629654/building-caffe-failed-to-see-hdf5-h
3. https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213 3. https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM