ubuntu16.04+cuda8.0.44+cudnn5.1.5+caffe问题集

小鱼是已经装好了ubuntu+cuda|+cudnn的,如果之前没有装好,可以网上百度一下,有很多教程。
可以参考小鱼的查找ubuntu+cuda+cudnn版本

这里小鱼主要是记录在安装caffe的过程中遇到的问题
1、下载caffe:

git clonehttps://github.com/BVLC/caffe.git

修改文件

cp Makefile.config.example Makefile.config
Vim Makefile.config
如果只使用CPU计算,去掉CPU_ONLY := 1前面的#
修改为:CPU_ONLY := 1
修改BLAS:=open
将use_cudnn :=1的备注取消

修改下面配置:
`NCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/

LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ `

在Makefile文件的第173行,把 hdf5_hl 和hdf5修改为hdf5_serial_hl 和 hdf5_serial,也就是把下面第一行代码改为第二行代码。

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

2、安装各种依赖包
记得先sudo apt-get update再下载各种包

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev

3、开始编译

make all

错误1:

CXX src/caffe/internal_thread.cpp
src/caffe/internal_thread.cpp:1:28: fatal error: boost/thread.hpp: No such file or directory compilation terminated.
Makefile:581: recipe for target '.build_release/src/caffe/internal_thread.o' failed
make: *** [.build_release/src/caffe/internal_thread.o] Error 1

解决办法:

sudo apt-get install --no-install-recommends libboost-all-dev

错误2、

./include/caffe/util/db_lmdb.hpp:8:18: fatal error: lmdb.h: 没有那个文件或目录

解决办法:

sudo apt-get install liblmdb-dev

错误3、

tools/caffe.cpp:6:27: fatal error: gflags/gflags.h: 没有那个文件或目录

解决办法:

sudo apt-get install libgflags-dev

错误4:

./include/caffe/util/math_functions.hpp:7:26: fatal error: glog/logging.h: 没有那个文件或目录

解决办法:

sudo apt-get install libgoogle-glog-dev

错误5:

collect2: error: ld returned 1 exit status Makefile:625: recipe for
target ‘.build_release/tools/convert_imageset.bin’ failed make: *
[.build_release/tools/convert_imageset.bin] Error 1

更多类似的错误都是因为gcc版本不一样:
解决方案:

1、cat /proc/driver/nvidia/version
//gcc版本,如5.4.0
2、nvcc -V
若nvcc未安装,则
sudo apt install nvidia-cuda-toolkit
4、gcc –versiom
//查看安装的gcc版本,会发现不一样,如4.8.5
5、gcc -V
//只能看到4.8.5版本的
//开始解决
6、ll /usr/bin/gcc*
7、which gcc
8、ll /usr/bin/gcc
9、sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc -f
10、sudo ln -s /usr/bin/gcc++c-5 /usr/bin/gcc -f
11、sudo ln -s /usr/bin/gcc++-5 /usr/bin/g++ -f
12、gcc -v
会提示没有这个文件或目录,没关系,继续往下
13、sudo ln -s /usr/bin/gcc-5* /usr/bin/gcc -f
14、gcc -v
这个时候有有gcc版本了,是5.4.0
15、sudo ln -s /usr/bin/g++-5* /usr/bin/g++ -f
g++ -v
也变成5.4.0版本了

这样就解决该问题,可cd caffe进行make all啦。
参考链接:gcc版本问题
问题6:

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).

解决办法:
在makefile.config 文件中 删除相关的行.即可
删除前

CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
        -gencode arch=compute_20,code=sm_21 \
        -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50

删除后

CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \
        -gencode arch=compute_35,code=sm_35 \
        -gencode arch=compute_50,code=sm_50 \
        -gencode arch=compute_50,code=compute_50

在编译的时候就没有警告了.
错误6:

[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.2.0 of the Protocol Buffer runtime library, but the installed version is 2.6.1.  Please update your library.  If you compiled the program yourself, make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification failed in "google/protobuf/descriptor.pb.cc".)

解决方法:

sudo pip uninstall protobuf
然后再重新安装:
sudo pip install protobuf==2.6.1
如果是python2的话
先sudo pip2 uninstall protobuf
sudo pip2 install protobuf==2.6.1

更多问题小鱼会不断更新,喜欢请点个赞哦。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值