《智能系统与技术丛书 深度学习实践:基于Caffe的解析》—2.3.2Nvidia CUDA Toolkit的安装
2.3.2 Nvidia CUDA Toolkit的安装(*.deb方法)
对于Nvidia CUDA Toolkit的安装,笔者在此特别推荐“*.deb”的方法,目前已有提供离线版的deb文件,该方法比较简单,不需要切换到tty模式,下面以CUDA 8.0为例。
1. CUDA Repository
首先,需要获取CUDA安装包,请自行去Nvidia官网上下载: https://developer.nvidia.com/cuda-downloads。
然后通过cd命令转到安装包所在的路径,比如我将文件下载到了/home/user/Downloads文件夹下,下面直接在终端通过cd命令转到该文件夹即可,示例代码如下:
$ cd ~/Downloads
$ sudo dpkg -i cuda-repo-ubuntu1504-8-0-local_8.0-18_amd64.deb
$ sudo apt-get update
$ sudo apt-get install -y cuda
2. 安装cuda sample(cuda的例子)
安装命令如下:
$ cd /usr/local/cuda-8.0/samples
$ sudo make –j32
全部编译完成之后,进入 samples/bin/x86_64/linux/release,然后在sudo下运行deviceQuery:
$ sudo./deviceQuery
如果出现下列显卡信息,则表示驱动及显卡安装成功:
$ ./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "GeForce GTX 1080"
CUDA Driver Version / Runtime Version 8.0 / 8.0
CUDA Capability Major/Minor version number: 3.0
Total amount of global memory: 8192 MBytes (8494246400 bytes)
( 7) Multiprocessors, (192) CUDA Cores/MP: 1344 CUDA Cores
GPU Clock rate: 1098 MHz (1.10 GHz)
Memory Clock rate: 3105 Mhz
Memory Bus Width: 256-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: Yes
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 Bus ID / PCI location ID: 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 GTX 1080
Result = PASS
如果sample测试没有通过,那么一般是显卡驱动的问题,根据提示可以先在Nvidia官网上下载Linux下最新的显卡驱动,其名称一般是“*.run”,调出终端,输入如下所示的命令:
$ sudo gedit /etc/modprobe.d /blacklist.conf
然后,在blacklist.conf文件的最后加上如下内容:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modest=0
alias nouveau off
alias lbm-nouveau off
或者:
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
(这里有一行空格)
再删除卸载旧的Nvidia驱动,命令如下:
sudo apt-get –purge remove nvidia-*(需要清除干净)
sudo apt-get –purge remove xserver-xorg-video-nouveau
之后再按Ctrl+Alt+F2进入tty2模式,进入系统后输入如下命令:
$ sudo services lightdm stop
通过cd命令转到“*.run”文件所在的文件夹中,执行如下命令:
$ sudo chmod –R 777 *.run
$ ./*.run
驱动安装完成之后,再输入如下命令:
$ sudo services lightdm start
若能启动,则证明驱动安装没有问题。
最后再通过下面的命令重启电脑:
$ sudo reboot
若要查看驱动型号,则可以使用如下命令:
$sudo nvidia-smi
完成上述步骤之后,再重新安装cuda,直到sample测试通过为止。
- 点赞
- 收藏
- 关注作者
评论(0)