安装环境
显卡型号:Nvidia GeForce GTX TITAN X(pascal)
系统:ubuntu16.04
1、给出cuda下载地址(含历史版本):
https://developer.nvidia.com/cuda-toolkit-archive
选择合适的版本。
2、下载cuda(使用run类型),依次选择:
Operating System:linux
Architecture:x86_64
Distribution:ubuntu
Version:16.04
Installer Type:runfile(local)
3、安装显卡驱动:
sudo apt-get install nvidia-367
该方法不需要关闭nouveau和lightdm,如果出现依赖问题可以尝试换源。
在楼主的环境中使用阿里云的源安装成功。
安装完成后,输入nvidia-smi测试。结果如下:
ubuntu@ubuntu-pc:~$ nvidia-smi
Fri Jan 19 22:02:51 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 TITAN X (Pascal) Off | 00000000:02:00.0 On | N/A |
| 23% 26C P0 53W / 250W | 182MiB / 12188MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1081 G /usr/lib/xorg/Xorg 138MiB |
| 0 1860 G compiz 41MiB |
+-----------------------------------------------------------------------------+
3、安装cuda
Run `sudo shcuda_8.0.44_linux.run` and Follow the command-line prompts
运行cuda文件,根据提示输入一些y或n,主要是一些默认安装位置的选择和相关库的安装。因为前面已经安装过显卡驱动,该步不需要再安装显卡驱动,选择n即可。
4、测试cuda
打开cuda8.0 Samples默认安装路径(在第三步的相关选项中会提示设置,默认为:/home/ubuntu/NVIDIA_CUDA-8.0_Samples,ubuntu为用户名)编译:
sudo make all -j4
某些教程可能提到gcc版本过高的问题,我的ubuntu16.04默认gcc版本为5.4,编译没有出现问题。
编译完成后,在当前目录继续输入:
cd bin/x86_64/linux/release
./deviceQuery
出现下面报告,说明安装成功。
ubuntu@ubuntu-pc:~/NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release$./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version(CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "TITAN X(Pascal)"
CUDA Driver Version / Runtime Version 9.0 / 8.0
CUDA Capability Major/Minor version number: 6.1
Total amount of global memory: 12189 MBytes (12780699648bytes)
(28) Multiprocessors, (128) CUDA Cores/MP: 3584 CUDA Cores
GPU Max Clock rate: 1531 MHz (1.53 GHz)
Memory Clock rate: 5005 Mhz
Memory Bus Width: 384-bit
L2 Cache Size: 3145728 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536),3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 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 2 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 Domain ID / Bus ID / location ID: 0 / 2 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() withdevice simultaneously) >
deviceQuery, CUDA Driver = CUDART,CUDA Driver Version = 9.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 =TITAN X (Pascal)
Result = PASS
5、添加环境变量
使用gedit编辑bashrc文件:
sudo gedit ~/.bashrc
在最后添加两行(cuda安装在默认位置时):
exportPATH=/usr/local/cuda-8.0/bin:$PATH
exportLD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
然后使用:source ~/.bashrc,使修改立即生效。
接下来可以继续安装cudnn和其他库。