【问题标题】:How to install caffe for python3 in ubuntu如何在ubuntu中为python3安装caffe
【发布时间】:2017-02-11 11:32:12
【问题描述】:

我按照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/

然后做了:

make all
make test
make runtest

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

make pycaffe

我收到一个错误:

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

我该如何解决这个问题?

【问题讨论】:

    标签: python python-3.x caffe pycaffe


    【解决方案1】:

    您可能必须链接到不同的 python_boost 版本。

    在 Makefile 中找到以下行:

    PYTHON_LIBRARIES ?= boost_python....
    

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

    PYTHON_LIBRARIES ?= boost_python-py35 python3.5m
    

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

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

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

    【讨论】:

    • 我在 Makefile 中找到了 'PYTHON_LIBRARIES ?= boost_python python2.7',所以我应该将其更改为 PYTHON_LIBRARIES ?= boost_python python3.5 吗?
    • 你必须改变两者。
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      所有这些库应该已经在你的 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
      

      另请参阅:
      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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-09-08
        • 1970-01-01
        • 2014-09-07
        • 1970-01-01
        • 2020-08-15
        • 2021-10-17
        • 2015-08-20
        • 1970-01-01
        相关资源
        最近更新 更多