版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1437707
主要还是要参考官方文档
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
—————————————吐槽分割线——————————————————
这一步需要检查
GPU是否支持CUDA
Ubuntu版本是否受支持
gcc版本检查
Kernel Headers and Development Packages 是否已安装
这些步骤官方教程很详细,请移步官方教程第二节Pre-installation Actions
CUDA Toolkit下载地址
根据自己的系统一步一步选择,注意主要下载的是.deb文件
在deb所在目录下依次执行以下命令即可。
重启系统然后进行验证
官方文档也很清楚,请移步官方简称的7.2.3节Verify the Installation
cudnn 安装:
2.3.1. Installing from a Tar File
2.3.2. Installing from a Debian File
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.