caffe-segnet-cudnn5安装

1 安装依赖包

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

sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

sudo apt-get install git cmake build-essential

2 安装英伟达显卡驱动

超简单的方法!!!
在这里插入图片描述
在这里插入图片描述

3 安装cuda8.0+cudnn5.1

下载cuda8.0 进入 https://developer.nvidia.com/cudadownloads ,依次选择 CUDA 类型然后下载。
在这里插入图片描述
在这里插入图片描述
安装 cuda8.0

sudo sh cuda_8.0.61_375.26_linux.run --no-opengl-libs

除了第二项“”是否安装显卡驱动“选择no之外,其他全部按照默认设定

安装过程显示如下信息

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: n   (!!!注意:这里要选n)

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]: 

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /home/username ]: 

Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...

Missing recommended library: libGLU.so
Missing recommended library: libX11.so
Missing recommended library: libXi.so
Missing recommended library: libXmu.so
Missing recommended library: libGL.so
Installing the CUDA Samples in /home/username ...
Copying samples to /home/username/NVIDIA_CUDA-8.0_Samples now...
Finished copying samples.
===========
= Summary =
===========
Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-8.0
Samples:  Installed in /home/username, but missing recommended libraries
Please make sure that

- PATH includes /usr/local/cuda-8.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.

***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 361.00 is required for CUDA 8.0 functionality to work.

To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run -silent -driver
Logfile is /tmp/cuda_install_8175.log

设置环境变量

sudo vi /etc/profile 

在文件最后加上下面两句(如果你安装时使用的是默认路径的话)

export PATH=/usr/local/cuda-8.0/bin:$PATH  
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH  

使环境变量立即生效

sudo ldconfig

验证 CUDA 8.0 是否安装成功
分别执行以下命令:

cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery

sudo make

./deviceQuery

若看到类似以下信息则说明 cuda 已安装成功:

./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GT 740M"
  CUDA Driver Version / Runtime Version          8.0 / 8.0
  CUDA Capability Major/Minor version number:    3.5
  Total amount of global memory:                 2004 MBytes (2100953088 bytes)
  ( 2) Multiprocessors, (192) CUDA Cores/MP:     384 CUDA Cores
  GPU Max Clock rate:                            1032 MHz (1.03 GHz)
  Memory Clock rate:                             800 Mhz
  Memory Bus Width:                              64-bit
  L2 Cache Size:                                 524288 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
  Maximum Layered 1D Texture Size, (num) layers  1D=(16384), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(16384, 16384), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 8.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GT 740M
Result = PASS

安装 cudnn5.1
登录官网:https://developer.nvidia.com/rdp/cudnn-archive ,下载对应 cuda 版本且 linux 系统的 cudnn 压缩包,注意官网下载 cudnn 需要注册帐号并登录。
在这里插入图片描述
下载后解压,然后得到一个cuda文件夹,(cd到cuda文件夹所在目录)然后执行下列命令

sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*

# 建立软链接,尤其注意生成的libcdnn的版本,要根据自己的自行调整
cd /usr/local/cuda/lib64/
sudo rm -rf libcudnn.so libcudnn.so.5    #删除原有动态文件
sudo ln -sf libcudnn.so.5.1.10 libcudnn.so.5  
sudo ln -sf libcudnn.so.5 libcudnn.so  
sudo ldconfig  

sudo ldconfig /usr/local/cuda/lib64/ #这句话也要写,不然会报找不到libcudnn.so.5 动态链接文件的错误

安装完成后可用 nvcc -V 命令验证是否安装成功,若出现以下信息则表示安装成功:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

4 安装opencv2.4.13

参考之前ORB-SLAM2安装教程中的opencv安装方法。
【SLAM】Ubuntu16.04下配置ORB-SLAM2
安装编译工具

sudo apt-get install build-essential -y

安装依赖包

sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y

安装可选包

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -y

sudo apt-get install libgtk2.0-dev -y

sudo apt-get install pkg-config -y

进入~/catkin_ws/src
从GitHub下载opencv2.4.13,这不是一个 git repository,使用wget。
将下载的OpenCV解压~/catkin_ws/src目录下。

wget https://github.com/Itseez/opencv/archive/2.4.13.zip

unzip 2.4.13.zip

进入OpenCV的目录下,编译安装OpenCV 2.4.13 源码。

cd opencv-2.4.13/

mkdir build

cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 

make

sudo make install

配置OpenCV环境变量

sudo vim /etc/ld.so.conf.d/opencv.conf

末尾加入/usr/local/lib,保存退出。

sudo ldconfig    

使配置生效

sudo gedit /etc/bash.bashrc 

末尾加入
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH
保存退出。

sudo source /etc/bash.bashrc  #使配置生效
sudo source /etc/bash.bashrc 

[sudo] password for slam2: 
sudo: source: command not found #报错找不到命令

该步骤可能会报错找不到命令,原因是source是root命令。

su  #(进入root权限)

输入root密码

source /etc/bash.bashrc
Ctrl+d  #(退出root)
sudo updatedb #更新database

5 编译caffe-segnet-cudnn5

首先在安装的路径下 clone :

git clone https://github.com/TimoSaemann/caffe-segnet-cudnn5.git

进入 caffe ,将 Makefile.config.example 文件复制一份并更名为 Makefile.config ,也可以在 caffe-segnet目录下直接调用以下命令完成复制操作 :

sudo cp Makefile.config.example Makefile.config

然后修改 Makefile.config 文件,在caffe-segnet 目录下打开该文件:

sudo gedit Makefile.config

修改 Makefile.config 文件内容:
应用 cudnn

#USE_CUDNN := 1
修改成: 
USE_CUDNN := 1

应用 opencv 版本

#OPENCV_VERSION := 3 
修改为: 
OPENCV_VERSION := 3

使用 python 接口

#WITH_PYTHON_LAYER := 1 
修改为 
WITH_PYTHON_LAYER := 1

修改 python 路径

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 
修改为: 
INCLUDE_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 /usr/lib/x86_64-linux-gnu/hdf5/serial       

然后修改 caffe-segnet目录下的 Makefile 文件:

将:
NVCCFLAGS +=-ccbin=$(CXX) -Xcompiler-fPIC $(COMMON_FLAGS)
替换为:
NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
将:
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

然后修改 /usr/local/cuda/include/host_config.h 文件 :

#error-- unsupported GNU version! gcc versions later than 5.0 are not supported!
改为
//#error-- unsupported GNU version! gcc versions later than 5.0 are not supported!

开始编译,在caffe-segnet目录下执行 :

make all -j4

测试编译是否成功:

sudo ldconfig /usr/local/cuda/lib64
sudo make test -j4
sudo make runtest -j4 

在这里插入图片描述
如果显示结果为上图所示,则表示 caffe-segnet已经成功安装。

参考文章

  1. Ubuntu16.04 Caffe 安装步骤记录(超详尽)
  2. Ubuntu16.04 + GTX1070 + CUDA8.0 + cudnn5.1 + Caffe + Tensorflow
  3. 【SLAM】Ubuntu16.04下配置ORB-SLAM2
  • 6
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值