使用python3.6编译caffe

一、前言

使用snpe转换模型,调用的是python3
系统是ubuntu18.04

二、安装python3.6

使用anaconda安装python3.6和requirements.txt中的依赖(不用写版本号,都满足)
conda create -n snpe python=3.6

三、修改Makefile.config

0.因为是用来转换模型,所以不用GPU和opencv
1.注释USE_CUDNN := 1
2.打开CPU_ONLY := 1和USE_OPENCV := 0
3.PYTHON_INCLUDE改为anaconda中python3.6的路径,有两个:anaconda3/envs/snpe/includeanaconda3/envs/snpe/include/python3.6m
4.打开PYTHON_LIBRARIES := boost_python3 python3.6m
5.PYTHON_LIB 改为anaconda3/envs/snpe/lib

四、编译

make all
make pycaffe

五、转换模型

snpe-caffe-to-dlc --input_network /home/liu/caffe/models/bvlc_alexnet/deploy.prototxt --caffe_bin /home/liu/caffe/models/bvlc_alexnet/bvlc_alexnet.caffemodel

九、遇到的问题

  • 1.undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE这个是因为PYTHON_LIBRARIES没有设置正确
  • 2.dynamic module does not define module export function因为使用了错误版本的python,执行命令export PYTHONPATH="anaconda3/envs/snpe:$PYTHONPATH"
  • 3.找不到python库,执行命令export LD_LIBRARY_PATH=anaconda3/envs/snpe/lib:$LD_LIBRARY_PATH"

20211116

  • 今天把opencv也编译进去了,需要在anaconda安装opencv
  • 遇到问题:.build_release/lib/libcaffe.so: undefined reference to cv::VideoWriter::write(cv::Mat const&),在Makefileifeq ($(USE_OPENCV), 1)的下一行添加库opencv_videoio

你可能感兴趣的:(deeplearning,caffe,深度学习)