ubuntu编译caffe

https://blog.csdn.net/weixin_42068754/article/details/103386379?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-103386379-blog-117161867.pc_relevant_aa_2&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-103386379-blog-117161867.pc_relevant_aa_2&utm_relevant_index=1

https://blog.csdn.net/yhaolpz/article/details/71375762

问题1:
caffe install ./include/caffe/common.hpp:4:32: fatal error: boost/shared_ptr.hpp: No such file or d
https://blog.csdn.net/luoganttcc/article/details/122686940

问题2:
./include/caffe/common.hpp:5:10: fatal error: gflags/gflags.h: No such file or directory
#include <gflags/gflags.h>
^~~~~~~~~~~~~~~~~
compilation terminated.

https://blog.csdn.net/u013171226/article/details/107813202
sudo apt-get install libgflags-dev

问题3:
protoc版本不一致
./include/caffe/proto/caffe.pb.h:17:2: error: #error This file was generated by an older version of protoc which is
#error This file was generated by an older version of protoc which is
^~~~~
./include/caffe/proto/caffe.pb.h:18:2: error: #error incompatible with your Protocol Buffer headers. Please
#error incompatible with your Protocol Buffer headers. Please
^~~~~
./include/caffe/proto/caffe.pb.h:19:2: error: #error regenerate this file with a newer version of protoc.
#error regenerate this file with a newer version of protoc.

https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/88737847

问题4:
安装opencv
https://blog.csdn.net/qq_42950957/article/details/123899581
再添加并测试
https://blog.csdn.net/weixin_44847326/article/details/123891105
最后查看版本

pkg-config opencv --modversion
4.5.3

安装完opencv,测试没有问题,但是编译caffe还是报错:
examples/cpp_classification/classification.cpp:3:10: fatal error: opencv2/core/core.hpp: No such file or directory
#include <opencv2/core/core.hpp>
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
于是直接在Makefile.config添加路径:

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial /usr/local/include/opencv4

版本不对,报错:

src/caffe/layers/window_data_layer.cpp:293:42: error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
         cv_img = cv::imread(image.first, CV_LOAD_IMAGE_COLOR);
                                          ^~~~~~~~~~~~~~~~~~~
src/caffe/layers/window_data_layer.cpp:293:42: note: suggested alternative: ‘CV_IS_IMAGE_HDR’
         cv_img = cv::imread(image.first, CV_LOAD_IMAGE_COLOR);
                                          ^~~~~~~~~~~~~~~~~~~
                                          CV_IS_IMAGE_HDR

应该使用 cv::IMREAD_COLOR 来代替CV_LOAD_IMAGE_COLOR。

将CV_LOAD_IMAGE_COLOR 改成 cv::IMREAD_COLOR

将CV_LOAD_IMAGE_GRAYSCALE 改成 cv::IMREAD_GRAYSCALE
/usr/local/lib/pkgconfig$ cat opencv.pc 
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: opencv
Description: The opencv library
Version:4.5.3
Cflags: -I${includedir}/opencv4
Libs: -L${libdir} -lopencv_stitching -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann  -lopencv_core
~
zhanglu@zhanglu-desktop:/usr/local/lib/pkgconfig$

sudo make -j8成功了
sudo make runtest -j8报错:
.build_release/tools/caffe: error while loading shared libraries: libhdf5_hl.so.100: cannot open shared object file: No such file or directory
Makefile:543: recipe for target ‘runtest’ failed
make: *** [runtest] Error 127
得安装hdf5:安装过程报错

$ sudo ./configure --prefix=/usr/local/hdf5
creating cache ./config.cache
checking host system type... Invalid configuration `x86_64-unknown-linux-gnu': machine `x86_64-unknown' not recognized

checking shell variables initial values... done
checking for cached host... none
checking for config --... no
checking for config --... no
checking for config -... no
checking for config -... no
checking for config -... no
checking for config -... no
checking for config -... no
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking whether make sets ${MAKE}... yes
checking for a BSD compatible install... /usr/bin/install -c
checking for ranlib... ranlib
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
ltconfig: you must specify a host type if you use `--no-verify'
Try `ltconfig --help' for more information.
configure: error: libtool configure failed

就找了其他路径的两个包,复制到/usr/lib/x86_64-linux-gnu中,问题解决。
zl@zl-desktop:/usr/lib/x86_64-linux-gnu$ sudo cp /home/zhanglu/anaconda3/lib/libhdf5_hl.so.100 .

zl@zl-desktop:/usr/lib/x86_64-linux-gnu$ sudo cp /home/zhanglu/anaconda3/lib/libhdf5.so.101 .

$ sudo make runtest -j8编译成功
在这里插入图片描述$ sudo make pycaffe -j10编译成功
在这里插入图片描述在这里插入图片描述$ pip install --upgrade google-api-python-client
在这里插入图片描述在这里插入图片描述成功了

运行模型转化,版本问题 报错。

在这里插入图片描述
scikit-image 0.13.1
$ pip install -U scikit-image
升级到Successfully installed PyWavelets-1.1.1 scikit-image-0.17.2 tifffile-2020.9.3
问题解决。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值