Ubuntu16:cmake生成Makefile编译caffe过程(OpenBLAS/CPU+GPU)塈解决nvcc warning:The 'compute_20', 'sm_20'

前端之家收集整理的这篇文章主要介绍了Ubuntu16:cmake生成Makefile编译caffe过程(OpenBLAS/CPU+GPU)塈解决nvcc warning:The 'compute_20', 'sm_20'前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

之前在ubuntu14下实现了Caffe编译(参见去年写的博客 《 Ubuntu14:cmake生成Makefile编译caffe过程(OpenBLAS/CPU only)》)。
最近将系统升级到ubuntu16,新电脑显示支持CUDA了,重新编译Caffe时发现还依赖库还是有点不同,在这里记下来。

硬件配置

神舟Z7M-SL7D2笔记本
cpu Core i7-6700HQ(含集成显卡)
芯片组 Intel Hm170
独立显卡 NVIDIA GTX965M

软件环境

ubuntu 16.04
NVIDIA driver 378
CUDA8.0
cudnn 5.1

编译环境准备

安装编译Caffe所需的依赖库

#!/bin/bash
sudo apt-get install cmake
sudo apt-get install libprotobuf-dev protobuf-compiler libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev 
sudo apt-get install libboost-all-dev   // 安装boost库
#sudo apt-get install libatlas-base-dev //BLAS如使用OpenBLAS,可不安装
sudo apt-get install libopenblas-dev    //BLAS如使用atlas,可不安装
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install python-numpy  // 安装numpy
#sudo apt-get install doxygen // doxygen用于文档生成 可不安装

编译caffe

以下是编译caffe的脚本(解压,生成Makefile,编译,安装全过程)
build_caffe.sh

#!/bin/bash
caffe_folder=caffe-master
if [ -d $caffe_folder ]
then 
    rm -fr $caffe_folder
fi
# 从 https://github.com/BVLC/caffe 下载Caffe源码 caffe-master.zip解压缩
unzip $caffe_folder.zip 
pushd $caffe_folder
# 创建编译输出文件
mkdir build && cd build
# 执行cmake生成Makefile
#编译cpu版本
#cmake -Dcpu_ONLY=ON -DBLAS=Open ..
#编译GPU版本
cmake -DBLAS=Open -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets .. 
# 开始编译并安装到build/install文件夹下 并发8线程
make install -j 8
cd ..
popd

消除NVCC警告

在这里 -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets用于指定CUDA编译器(nvcc)的编译选项,如果不指定--Wno-deprecated-gpu-targets选项则在编译Caffe时会产生如下编译警告

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).

当然也可以在cmake-gui中,如下图搜索NVCC,在CUDA_NVCC_FLAGS中添加--Wno-deprecated-gpu-targets

执行cmake -DBLAS=Open -DCUDA_NVCC_FLAGS=--Wno-deprecated-gpu-targets ..输出如下

-- Boost version: 1.58.0 -- Found the following Boost libraries: -- system -- thread -- filesystem -- chrono -- date_time -- atomic -- Found gflags (include: /usr/include,library: /usr/lib/x86_64-linux-gnu/libgflags.so) -- Found glog (include: /usr/include,library: /usr/lib/x86_64-linux-gnu/libglog.so) -- Found PROTOBUF Compiler: /usr/bin/protoc -- Found lmdb (include: /usr/include,library: /usr/lib/x86_64-linux-gnu/liblmdb.so) -- Found LevelDB (include: /usr/include,library: /usr/lib/x86_64-linux-gnu/libleveldb.so) -- Found Snappy (include: /usr/include,library: /usr/lib/x86_64-linux-gnu/libsnappy.so) -- CUDA detected: 8.0 -- Found cuDNN: ver. 5.1.10 found (include: /usr/local/cuda-8.0/include,library: /usr/local/cuda-8.0/lib64/libcudnn.so) -- Automatic GPU detection Failed. Building for all known architectures. -- Added CUDA NVCC flags for: sm_20 sm_21 sm_30 sm_35 sm_50 -- OpenCV found (/usr/share/OpenCV) -- Found OpenBLAS libraries: /usr/lib/libopenblas.so -- Found OpenBLAS include: /usr/include -- NumPy ver. 1.11.0 found (include: /usr/lib/python2.7/dist-packages/numpy/core/include) -- Boost version: 1.58.0 -- Found the following Boost libraries: -- python -- Detected Doxygen OUTPUT_DIRECTORY: ./doxygen/ -- -- ******************* Caffe Configuration Summary ******************* -- General: -- Version : 1.0.0-rc3 -- Git : unknown -- System : Linux -- C++ compiler : /usr/bin/c++ -- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized -- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized -- Build type : Release -- -- BUILD_SHARED_LIBS : ON -- BUILD_python : ON -- BUILD_matlab : OFF -- BUILD_docs : ON -- cpu_ONLY : OFF -- USE_OPENCV : ON -- USE_LEVELDB : ON -- USE_LMDB : ON -- ALLOW_LMDB_NOLOCK : OFF -- -- Dependencies: -- BLAS : Yes (Open) -- Boost : Yes (ver. 1.58) -- glog : Yes -- gflags : Yes -- protobuf : Yes (ver. 2.6.1) -- lmdb : Yes (ver. 0.9.17) -- LevelDB : Yes (ver. 1.18) -- Snappy : Yes (ver. 1.1.3) -- OpenCV : Yes (ver. 2.4.9.1) -- CUDA : Yes (ver. 8.0) -- -- NVIDIA CUDA: -- Target GPU(s) : Auto -- GPU arch(s) : sm_20 sm_21 sm_30 sm_35 sm_50 -- cuDNN : Yes (ver. 5.1.10) -- -- Python: -- Interpreter : /usr/bin/python2.7 (ver. 2.7.12) -- Libraries : /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12) -- NumPy : /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0) -- -- Documentaion: -- Doxygen : /usr/bin/doxygen (1.8.11) -- config_file : /home/guyadong/caffe/caffe-master/.Doxyfile -- -- Install: -- Install path : /home/guyadong/caffe/caffe-master/build/install -- -- Configuring done -- Generating done -- Build files have been written to: /home/guyadong/caffe/caffe-master/build
原文链接:https://www.f2er.com/ubuntu/354102.html

猜你在找的Ubuntu相关文章