Ubuntu16.0.4+1080ti+ cuda9.1+cudnn7.0.5 安装 及 caffe 测试

主要还是要参考官方文档
cuda 安装有两种方法,这里参考
blog.csdn.net/guojunxiu/article/details/78848503
使用 Package Manager Installation的方法

目前网上大部分教程都是Runfile Installation安装的,然而这中方法很繁琐,需要关X Server,禁用nouveau等等,还会出现无法开机、无限循环登录等一些列毁天灭地的后果。如果侥幸顺利安装后,一个”CUDA driver version is insufficient for CUDA runtime version”的错误可以让你玩一年~
装了N次之后我已经有些绝望了,后来发现还有一种Package Manager Installation的方法,只需要四行命令就解决了,想起之前真的是天堂有路你不走,地狱无门你自投o(╥﹏╥)o

—————————————吐槽分割线——————————————————
1. Pre-installation Actions

这一步需要检查

GPU是否支持CUDA
Ubuntu版本是否受支持
gcc版本检查
Kernel Headers and Development Packages 是否已安装

这些步骤官方教程很详细,请移步官方教程第二节Pre-installation Actions
2. 下载Nividia Cuda Toolkit的deb安装包

CUDA Toolkit下载地址
根据自己的系统一步一步选择,注意主要下载的是.deb文件
3. 执行命令进行安装

在deb所在目录下依次执行以下命令即可。
1. sudo dpkg -i cuda-repo-ubuntu1604-9-1-local_9.1.85-1_amd64.deb
2. sudo apt-key add /var/cuda-repo-<\version>/7fa2af80.pub # 这句命令有提示
3. sudo apt-get update
4. sudo apt-get install cuda
以上命令其实就是选择完deb安装包后,官方给出的安装说明。
deb安装包会安装CUDA Toolkit和Driver Package,不需要自己安装驱动
安装时好像也会自动设置环境变量,记不太清了~如果没有的话请查看官方教程7.1.1. Environment Setup,设置一下环境变量。
/// 这里是需要设置一下的,具体参考官方文档

  1. 验证安装

重启系统然后进行验证
1. 检查GPU驱动版本和NVCC版本
2. 编译NVIDIA_CUDA-9.1_Samples下的例子,然后跑两个可执行文件。

官方文档也很清楚,请移步官方简称的7.2.3节Verify the Installation

cudnn 安装:
2.3.1. Installing from a Tar File
1.
Navigate to your directory containing the cuDNN Tar file.
2.
Unzip the cuDNN package.
$ tar -xzvf cudnn-9.0-linux-x64-v7.tgz
3.
Copy the following files into the CUDA Toolkit directory.
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

2.3.2. Installing from a Debian File
1.
Navigate to your directory containing cuDNN Debian file.
2.
Install the runtime library, for example: 具体名称以下载的 deb文件名为准
sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb
3.
Install the developer library, for example:
sudo dpkg -i libcudnn7-dev_7.0.3.11-1+cuda9.0_amd64.deb
4.
Install the code samples and the cuDNN Library User Guide, for example:
sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.

caffe编译的问题解决:“cublas_v2.h: No such file or directory”

INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/lib/x86_64-linux-gnu/hdf5/serial/include /usr/local/cuda-9.1/targets/x86_64-linux/include

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

#

GTX1080 LetNet-5 CPU GPU cuDNN6.0 时间对比

CPU模式:
Makefile.config

CPU_ONLY:=1 前取消 #
make clean
make -j

./build/tools/caffe.bin time -model examples/mnist/lenet_train_test.prototxt
Testing for 50 iterations

Total Time: 2906 ms.

GPU 模式:

Makefile.config

#CPU_ONLY:=1
make clean
make -j

./build/tools/caffe.bin time -model examples/mnist/lenet_train_test.prototxt -gpu 0

Total Time: 370.198 ms.

cuDNN 模式:

Makefile.config

USE_CUDNN:=1

make clean
make -j

./build/tools/caffe.bin time -model examples/mnist/lenet_train_test.prototxt -gpu 0

Testing for 50 iterations.
Total Time: 68.2353 ms.

猜你喜欢

转载自blog.csdn.net/zhangjunhit/article/details/79402781