ubuntu16.04 安装caffe

主要部分参考博客链接为:https://www.cnblogs.com/xuanxufeng/p/6150593.html

make clean # 清理上次编译错误记录

make all -j8   #-j8是根据电脑配置,若低版本可用-j4

遇到错误如下:

1.

解决方案:本机环境为caffe9.0,Python3.6     sudo gedit makefile.config中,删除-gencode arch=compute_35,code=sm_20 \

                                    -gencode arch=compute_35,code=sm_21 \

2.

因为我们在安装caffe之前,安装Anaconda或tensorflow时都已经安装过libprotobuf,查看protoc 版本:

conda uninstall libprotobuf

3.找不到boost_python3

CXX examples/cifar10/convert_cifar_data.cpp
AR -o .build_release/lib/libcaffe.a
LD -o .build_release/lib/libcaffe.so.1.0.0
/usr/bin/ld: 找不到 -lboost_python3
collect2: error: ld returned 1 exit status
Makefile:585: recipe for target '.build_release/lib/libcaffe.so.1.0.0' failed
make: *** [.build_release/lib/libcaffe.so.1.0.0] Error 1

 

在caffe编译配置文件Makefile.config里面的PYTHON_LIBRARIES := boost_python3 python3.6m 一行中,找不到boost_python3造成的。

有人修改Makefile 文件(注意不是)Makefile.config 
将里面的
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

改为LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial但对于我来说不好用。

下面是参考的另一个:https://blog.csdn.net/u012505617/article/details/88556621

若使用的是Python3.5
进入/usr/lib/x86_64-linux-gnu/ 下,查看有没有libboost_python-py3.5.so,如果有链接一下就可以了

sudo ln -s libboost_python-py3.5.so libboost_python3.so

若为python3.6,需要自己编译libboost_python-py3.6.so 文件,方法如下

  下载 boost_1_67_0.tar.gz:

    # 进入文件夹

  1. cd boost_1_67_0/
  2.  # 生成 .so 文件 
  3. ./bootstrap.sh --with-libraries=python --with-toolset=gcc
  4.  ./b2 --with-python include="/home/ubuntu/anaconda3/include/python3.6m"

在boost_1_67_0文件夹的stage/lib下可以找到libboost_python3.6.so

  复制:[home/ubuntu/caffe/是你的下载文件所在目录]
  sudo cp /home/ubuntu/caffe/boost_1_67_0/stage/lib/libboost_python36.a /usr/lib/x86_64-linux-gnu/libboost_python-py36.a
  sudo cp  /home/ubuntu/caffe/boost_1_67_0/stage/lib/libboost_python36.so /usr/lib/x86_64-linux-gnu/libboost_python3.so

  链接:
  sudo ln -s libboost_python36.so libboost_python3.so
  sudo ln -s libboost_python36.a libboost_python-py36.a       完成!!!

 

编译caffe:

make all
make test
make runtest

在python和matlab下使用caffe:
make pycaffe
make matcaffe
posted @ 2019-05-21 17:27  乖孩子306  阅读(390)  评论(0编辑  收藏  举报