caffe—ssd安装教程

编程入门 行业动态 更新时间:2024-10-09 06:28:26

caffe—ssd安装<a href=https://www.elefans.com/category/jswz/34/1771193.html style=教程"/>

caffe—ssd安装教程

环境:

ubuntu16.04 cuda8.0 cudnn5.0

已安装过caffe1.0 tensorflow1.2

 编辑过程中出现问题尽量到这里面搜一下:

教程  

Installation

  1. Get the code. We will call the directory that you cloned Caffe into $CAFFE_ROOT
git clone .git
cd caffe
git checkout ssd
  1. Build the code. Please follow Caffe instruction to install all necessary packages and build it.
# Modify Makefile.config according to your Caffe installation.
cp Makefile.config.example Makefile.config
make -j8
# Make sure to include $CAFFE_ROOT/python to your PYTHONPATH.
make py
make test -j8
# (Optional) make runtest -j8

问题:此处参考了别的教程使用了make all -j8出现问题(一定看官方教程)问题描述:
This file was generated by an older version of protoc which is incompatible with your Protocol Buffer headers. Please regenerate this file with a newer version of protoc.

原因是系统中装tensorflow时装有了多个版本的protobuf,造成版本冲突。将protobuf卸载后,按照此教程重新安装.html

  tar -xvf protobufcd protobuf./configure --prefix=/usr/local/protobufmakemake checkmake install

按照上边的还有问题,加上这部分

去*.tar.tz压缩包,解压,
命令行进入解压后目录,依次执行如下 
./configure 
make
创建文件 /etc/ld.so.conf.d/libprotobuf.conf 写入内容:/usr/local/lib 
输入命令 sudo ldconfig 
注:protobuf的默认安装路径是/usr/local/lib,而/usr/local/lib 不在Ubuntu体系默认的 LD_LIBRARY_PATH 里,后面install找不到该lib然后sudo make install安装后,输入protoc --version 验证是否安装成功

如果还有问题,参考:

然后输入protoc --version查看是否安装成功,报错:protoc: error while loading shared libraries: libprotoc.so.8: cannot open shared object file: No such file or directory

解决办法: export LD_LIBRARY_PATH=/usr/local/lib/      (这个可能需要写到环境变量里,否则会不会下次启动就不能用了)

 

装完一定要清理一下,一定要清理一下!! make clean!!! 继续编译,出现问题  ./include/caffe/util/hdf5.hpp:6:10: fatal error: hdf5.h: No such file or directory #include "hdf5.h  解决方式
install libhdf5-devadd patch to libhdf5 in Makefile.config.example: INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

参考:

 

继续编译,新的问题gcc版本过高, /usr/local/cuda/include/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions 

解决方案:降低gcc与g++版本到5,参考

gcc --verison查看gcc
(2)设置gcc的默认版本
设置之前可以先输入命令ls /usr/bin/gcc* 查看gcc 4.8版本是否安装成功
然后输入下面的命令设置默认版本:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 100
最后的数字为优先级(越大越高),因为只有一个4.8版本作为alternatives,可以不要纠结数字,这样设就行了
(3)然后可以输入以下命令查看设置结果(非必须)
sudo update-alternatives --config gcc
因为只设置了一个,所以显示结果为:"链接组 gcc (提供 /usr/bin/gcc)中只有一个候选项:/usr/bin/gcc-4.8
无需配置.",如果有多个则会显示一个按优先级的列表.
(4)最后再次输入命令gcc -version查看gcc的版本已经变成4.8啦...就成功啦.
现在默认版本已经是4.8版本,如果想用6.2版本,则gcc-6.2 这样指定就好啦
g++ 等其他软件也是这样设置进行版本升级/降级.ps:(1)当以上设置不需要的时候输入以下命令删除:sudo update-alternatives --remove gcc /usr/bin/gcc-4.8
--------------------- 
作者:帝江VII 
来源:CSDN 
原文: 
版权声明:本文为博主原创文章,转载请附上博文链接!
View Code

 

 

继续编译,出现问题

/usr/bin/ld: cannot find -lopencv_imgcodecs 
/usr/bin/ld: cannot find -lopencv_videoio 
collect2: error: ld returned 1 exit status 
Makefile:566: recipe for target ‘.build_release/lib/libcaffe.so.1.0.0-rc3’ failed 
make: * [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1

首先更新Makefile,不知道管没管用,参考

然后修改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
然后还是原问题,根据

Did you apt-get install libopenblas-base libopenblas-dev ?

 

继续编译,出现问题: .build_release/lib/libcaffe.so: undefined reference to `cv::VideoCapture::set(int, double)' .build_r 

solution:add "opencv_imgcodecs" in Makefile.(LIBRARIES += glog gflags protobuf leveldb snappy \
lmdb boost_system hdf5_hl hdf5 m \
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs)
If you input "make all",the problem is the same again.But if you delete all the file in build(rm -rf ./build/*) before "make all"(I use make clean ),you will success.I just successgithub 讨论帖:
参考链接:/
View Code

 另外opencv_videoio也要加上。

 

继续编译新问题出现 .build_release/lib/libcaffe.so: undefined reference to `boost::filesystem::detail::status(boost::fil 

解决方式:再加一个库boost_filesystem

第一步编译成功

 

二:make py

问题:

python/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
Makefile:501: recipe for target 'python/caffe/_caffe.so' failed
make: *** [python/caffe/_caffe.so] Error 1

解决方式:

如果还是不行,可以试试:import numpy as np
np.get_include()
得到:
/usr/local/lib/python2.7/dist-packages/numpy/core/include在Makefile.config找到PYTHON_INCLUDE,发现有点不同:PYTHON_INCLUDE := /usr/include/python2.7 \/usr/lib/python2.7/dist-packages/numpy/core/include要加一个local,变成: PYTHON_INCLUDE := /usr/include/python2.7 \/usr/local/lib/python2.7/dist-packages/numpy/core/include
再make pycaffe就ok了
View Code

参考:

 

 

三:

不要随便make clean 否则会出现 make: .build_release/tools/caffe: Command not found 

解决方式:make all 参考:

问题: Makefile:526: recipe for target 'runtest' failed make: *** [runtest] Segmentation fault 

解决方案:sf@ubuntu:~/caffe$ export MKL_CBWR=AUTO

不要make clean,然后重新make runtest

这个问题没有解决,但是看网上资料说这个不用全部运行成功也可以,就没有继续调试

 

然后在python环境下imoprt python,报错 ImportError: No module named caffe 

solution:

A.把环境变量路径放到 ~/.bashrc文件中,打开文件
sudo vim ~/.bashrc 在文件下方写入
export PYTHONPATH=~/caffe/python:$PYTHONPATH上述语句中 “~” 号表示caffe 所在的根目录。B.关闭文件,在终端写入下面语句,使环境变量生效
source ~/.bashrc
--------------------- 
作者:修炼打怪的小乌龟 
来源:CSDN 
原文: 
版权声明:本文为博主原创文章,转载请附上博文链接!
View Code

继续import,报错 ImportError: No module named google.protobuf.internal 

solution: sudo pip install protobuf 

转载于:.html

更多推荐

caffe—ssd安装教程

本文发布于:2024-02-14 12:02:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1763225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:教程   caffe   ssd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!