安裝NVIDIA顯卡驅動和CUDA-8.0運算平台
- 准備工作:下載安裝包
- 查看顯卡信息
lspci | grep -i vga
lspci -v -s 00:02.0
- 查看幾張GPU卡
lspci | grep NVIDIA
cuda_8.0.61_375.26_linux.run
NVIDIA-Linux-x86_64-384.66.run
- 依賴
kernels-3.10.0-514.21.2.el7.x86_64
內核源碼
編譯環境需要安裝gcc
- 查看顯卡信息
內核版本
內核下載地址 https://opsx.alibaba.com/
https://www.kernel.org/
查看內核版本 uname -r
ls /boot | grep vmlinuz
查看已安裝的內核包 rpm -aq | grep -i kernel
內核源碼存放位置 ll /usr/src/kernels/
步驟
-
卸載 cuda
sudo sh /usr/local/cuda-8.0/bin/uninstall_cuda_8.0.pl
-
然后卸載驅動
nvidia-installer --uninstall
- 命令路徑
/usr/bin/nvidia-installer
- 注意:正常卸載后,nvidia-smi 命令就沒了
- 命令路徑
-
安裝內核
解壓 kernels-3.10.0-514.21.2.el7.x86_64.tar.gz 到
/usr/src/kernels/
-
安裝英偉達顯卡驅動
sudo sh NVIDIA-Linux-x86_64-384.66.run
- 安裝后可測試nvidia-smi命令
-
安裝cuda-8.0
sudo sh cuda_8.0.61_375.26_linux.run
卸載NVIDIA-Linux-x86_64-384.66.run詳細步驟
1. TODO這步不是很明白什么意思?
If you plan to no longer use the NVIDIA driver, you should make sure that no X screens are configured to use the NVIDIA X driver in your X configuration file. If you used nvidia-xconfig to configure X, it may have created a backup of your original configuration. Would you like to run
nvidia-xconfig --restore-original-backup
to attempt restoration of the original X configuration file?
[Yes]選中yes回車 No
安裝 NVIDIA-Linux-x86_64-384.66.run詳細步驟
1. 進入安裝包目錄執行 sudo sh NVIDIA-Linux-x86_64-384.66.run
2. Accept 接受許可證並繼續安裝
Please read the following LICENSE and then select either "Accept" to accept the license and continue with the installation, or select "Do Not Accept" to abort the installation.
[Accept]選中Accept回車 Do Not Accept
3. 安裝Nvidia的32位兼容庫?
Install NVIDIA's 32-bit compatibility libraries?
Yes [No]選中NO回車
4.測試命令 nvidia-smi
安裝 cuda_8.0.61_375.26_linux.run
詳細步驟
1. 進入安裝包目錄執行 sudo sh cuda_8.0.61_375.26_linux.run
2. 閱讀協議,按s下一頁,直到100%閱讀完畢
3. 按照一下步驟執行
Do you accept the previously read EULA?
accept/decline/quit: acceptInstall NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit: y(若已安裝其它版本選擇no)Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: yEnter 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: nInstall the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: n
4. 耐心等待,顯示如下信息安裝成功
Installing the CUDA Toolkit in /usr/local/cuda-8.0 ...
= Summary =
Driver: Not Selected Toolkit: Installed in /usr/local/cuda-8.0 Samples: Not Selected
Please make sure that - PATH includes /usr/local/cuda-8.0/bin - LDLIBRARYPATH 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 CUDAInstallationGuide_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 with the name of this run file: sudo .run -silent -driver
Logfile is /tmp/cudainstall8566.log
5. 添加環境變量,在管理員用戶根目錄下,找到.bashrc文件並打開,在最后添加下面三行文本,保存退出即可
vim ~/.bashrc
# added by cuda_8.0 installer
export PATH="/usr/local/cuda-8.0/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH"
source ~/.bashrc
6. 檢測cuda是否安裝成功
-
方案一
執行nvcc -V,若顯示以下信息,則安裝cuda成功
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on TueJan1013:22:03CST_2017
Cuda compilation tools, release 8.0, V8.0.61 -
方案二
依次輸入以下命令,測試cuda的執行結果
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
-
若最后顯示Result = PASS,表明cuda查詢顯卡信息成功
-
最后執行sudo make clean清除垃圾文件,並重啟終端
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 9.1 / 8.0 CUDA Capability Major/Minor version number: 6.1 Total amount of global memory: 8118 MBytes (8511881216 bytes) (20) Multiprocessors, (128) CUDA Cores/MP: 2560 CUDA Cores GPU Max Clock rate: 1734 MHz (1.73 GHz) Memory Clock rate: 5005 Mhz Memory Bus Width: 256-bit L2 Cache Size: 2097152 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 / 1 / 0 Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.1, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GTX 1080
Result = PASS -
安裝NVIDIA-Linux-x86_64-384.66.run提示先安裝kernle-source或kernle-devel解決方案
下載kernle-source源碼包並解壓到/usr/src/kernles/目錄下