Caffe-MobileNetSSD下ncnn推理实现-5

安装caffe python接口

(py365) user@ubuntu:~/caffe_ssd/caffe$ pip install -r python/requirements.txt

pip3 install matplotlib

make pycaffe -j8

出现问题:

(py365) user@ubuntu:~/caffe_ssd/caffe$ make pycaffe -j8

touch python/caffe/proto/__init__.py

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

PROTOC (python) src/caffe/proto/caffe.proto

/usr/bin/ld: cannot find -lboost_python3

collect2: error: ld returned 1 exit status

Makefile:519: recipe for target 'python/caffe/_caffe.so' failed

make: *** [python/caffe/_caffe.so] Error 1

解决:

(py365) user@ubuntu:/usr/lib/x86_64-linux-gnu$ sudo ln -s libboost_python-py35.so libboost_python3.so

boost_python3

然后重新开始编译caffe

 

gedit ~/.bashrc

export PYTHONPATH=/home/user/caffe_ssd/caffe/python:$PYTHONPATH

Caffe-MobileNetSSD下ncnn推理实现-5_第1张图片

 

(py365) user@ubuntu:~/caffe_ssd/caffe$ source ~/.bashrc

(base) user@ubuntu:~/caffe_ssd/caffe$ python

Python 3.7.3 (default, Mar 27 2019, 22:11:17)

[GCC 7.3.0] :: Anaconda, Inc. on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import caffe

Traceback (most recent call last):

  File "", line 1, in

  File "/home/user/caffe_ssd/caffe/python/caffe/__init__.py", line 1, in

    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer

  File "/home/user/caffe_ssd/caffe/python/caffe/pycaffe.py", line 13, in

    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \

ImportError: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory

>>>

分析问题:

让Caffe支持Python3,https://www.jianshu.com/p/ea2156fa1206(参考设置conda create --name py365 python=3.6.5环境变量

解决方法:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python3/bin

https://www.cnblogs.com/laosan007/p/11737704.html

export PYTHONPATH=/home/user/caffe_ssd/caffe/python:$PYTHONPATH

export C_INCLUDE_PATH=$C_INCLUDE_PATH: /home/user/anaconda3/envs/py365/include:/home/user/anaconda3/envs/py365/include/python3.6m

export C_PLUS_INCLUDE_PATH=$C_PLUS_INCLUDE_PATH:/home/user/anaconda3/envs/py365/include:/home/user/anaconda3/envs/py365/include/python3.6m

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/anaconda3/envs/py365/lib

 

(py365) user@ubuntu:~/caffe_ssd/caffe/examples$ python

Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)

[GCC 7.2.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import caffe

/home/user/anaconda3/envs/py365/lib/python3.6/site-packages/scipy/__init__.py:144: UserWarning: Numpy 1.13.3 or above is required for this version of scipy (detected version 1.13.1)

  UserWarning)

>>> import caffe

>>>

 

参考:https://www.jianshu.com/p/ea2156fa1206

你可能感兴趣的:(Deep,Learning,移动端AI,Image,Algorithm)