caffe配置修改问题

首先cd进入caffe文件夹,然后执行命令

cp Makefile.config.example Makefile.config
gedit Makefile.config

此时将打开Makefile.config文件,根据个人情况对其内容进行修改。
a.若使用cudnn,则

 

 

 
  1. #USE_CUDNN := 1

  2. 修改成:

  3. USE_CUDNN := 1

 

b.若使用的opencv版本是3的,则

 
  1. #OPENCV_VERSION := 3

  2. 修改为:

  3. OPENCV_VERSION := 3

c.若要使用python来编写layer,则

 
  1. #WITH_PYTHON_LAYER := 1

  2. 修改为

  3. WITH_PYTHON_LAYER := 1

d. 重要的一项 :
将# Whatever else you find you need goes here.下面的

 
  1. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include

  2. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

  3. 修改为:

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

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

这是因为ubuntu16.04的文件包含位置发生了变化,尤其是需要用到的hdf5的位置,所以需要更改这一路径.

 

去掉compute_20

 

 
  1. 找到

  2. # CUDA architecture setting: going with all of them.

  3. # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.

  4. # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.

  5. # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.

  6. CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \

  7. -gencode arch=compute_20,code=sm_21 \

  8. -gencode arch=compute_30,code=sm_30 \

  9. -gencode arch=compute_35,code=sm_35 \

  10. -gencode arch=compute_50,code=sm_50 \

  11. -gencode arch=compute_52,code=sm_52 \

  12. -gencode arch=compute_60,code=sm_60 \

  13. -gencode arch=compute_61,code=sm_61 \

  14. -gencode arch=compute_61,code=compute_61

  15.  
  16. 改为:

  17. # CUDA architecture setting: going with all of them.

  18. # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.

  19. # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.

  20. # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility.

  21. CUDA_ARCH := -gencode arch=compute_30,code=sm_30 \

  22. -gencode arch=compute_35,code=sm_35 \

  23. -gencode arch=compute_50,code=sm_50 \

  24. -gencode arch=compute_52,code=sm_52 \

  25. -gencode arch=compute_60,code=sm_60 \

  26. #-gencode arch=compute_61,code=sm_61 \

  27. #-gencode arch=compute_61,code=compute_61



由于CUDA 9.x +并不支持compute_20,此处不修改的话编译caffe时会报错:

同时若非cuda8则注释掉compute_61

nvcc fatal   : Unsupported gpu architecture 'compute_20'

 

 

 

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

 
  1. 将:

  2. LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5

  3. 改为:

  4. LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_serial_hl hdf5_serial

在Makefile文件中第260行左右添加boost_regex,即

 

 

LIBRARIES += boost_thread stdc++后,如下

LIBRARIES += boost_thread stdc++ boost_regex

 

继续在Makefile文件中查找

 
  1. 将:

  2. NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)

  3. 替换为:

  4. NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)

  5.  
  6.  

 

第三步:编辑/usr/local/cuda/include/host_config.h 将其中的第115行注释掉:

 
  1. #error-- unsupported GNU version! gcc versions later than 4.9 are not supported!

  2. 改为

  3. //#error-- unsupported GNU version! gcc versions later than 4.9 are not supported!

第四步:将一些文件复制到/usr/local/lib文件夹下,解决"libcudart.so.8.0 cannot open shared object file: Nosuch fileor directory"

 
  1. #注意自己CUDA的版本号!

  2. cp /usr/local/cuda-8.0/lib64/libcudart.so.8.0 /usr/local/lib/libcudart.so.8.0 && sudo ldconfig

  3. cp /usr/local/cuda-8.0/lib64/libcublas.so.8.0 /usr/local/lib/libcublas.so.8.0 && sudo ldconfig

  4. cp /usr/local/cuda-8.0/lib64/libcurand.so.8.0 /usr/local/lib/libcurand.so.8.0 && sudo ldconfig

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值