linux mint18 +nvidia GTX 1060+CUDA 9.0

準備工作
1.檢查自己的GPU是否是CUDA-capable
在終端中輸入:

lspci | grep -i nvidia

01:00.0 VGA compatible controller: NVIDIA Corporation Device 1c03 (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 10f1 (rev a1)

2.在終端中輸入:

uname -r

可以查看自己的kernel版本信息

比如我的是
4.10.0-37-generic
那麼就上網查找我的4.10的內核對應的ubuntu版本,查到我的對應的內核是ubuntu17.4,cuda下載9.0(後面要用)

3.在終端裏面輸入:
sudo apt-get install linux-headers-$(uname -r)

可以安裝對應kernel版本的kernel header和package development

4.安裝nvidia驅動
可以在 程序啓動器–程序–設置–找到對應的推薦的nvidia 版本
sudo apt-get install nvidia-384.90

5 .查看nvidia的命令

nvidia-smi

比如我的是這樣子:
Thu Nov 30 15:28:20 2017
+—————————————————————————–+
| NVIDIA-SMI 384.90 Driver Version: 384.90 |
|——————————-+———————-+———————-+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 106… Off | 00000000:01:00.0 On | N/A |
| 49% 28C P8 9W / 120W | 309MiB / 6071MiB | 0% Default |
+——————————-+———————-+———————-+

+—————————————————————————–+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 1187 G /usr/lib/xorg/Xorg 41MiB |
| 0 1246 G /usr/bin/sddm-greeter 40MiB |
| 0 1845 G /usr/lib/xorg/Xorg 134MiB |
| 0 2014 G kwin_x11 25MiB |
| 0 2017 G /usr/bin/krunner 1MiB |
| 0 2019 G /usr/bin/plasmashell 62MiB |
+—————————————————————————–+

搜索nvidia驅動:

apt-cache search nvidia | more

  1. 幾個查看顯卡驅動情況的命令:

glxinfo | grep rendering

dpkg -l | grep nvidia

lspci | grep -i nvidia

lsmod | grep nvidia

7.正式安裝過程:

官網下載cuda-9.0.run(https://developer.nvidia.com/cuda-downloads);

這裏寫圖片描述

下載deb 包就可以了。

8.然後按照官方給的方法安裝cuda9.0
Installation Instructions:

sudo dpkg -i cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
(最後開始安裝cuda以及顯卡驅動(安裝cuda的同時就會把顯卡驅動也全部安裝好,這個真的很方便。但是下載的時間有點長,有人說安裝cuda的同時會把顯卡驅動安好,這個我沒有試過,但是我的建議是還是先把nvida的驅動安裝好)

9.安裝完畢後:
測試一下nvidia 信息:
nvidia-smi
如果沒有出錯,進行下一步,當然可以經常用第6步的命令查看下顯卡驅動
然後:
測試一下cuda的相關例子,我將 cuda9.0下的sample拷貝到一個臨時目錄下進行編譯:
cp -r /usr/local/cuda-9.0/samples/ .
cd samples/
make

然後運行幾個例子來看一下:

cd /usr/local/cuda-9.0/samples/1_Utilities/deviceQuery
make
sudo ./deviceQuery

如果顯示:

Detected 1 CUDA Capable device(s)

Device 0: “GeForce GTX 1060 6GB”
CUDA Driver Version / Runtime Version 9.0 / 9.0
CUDA Capability Major/Minor version number: 6.1
Total amount of global memory: 6071 MBytes (6366363648 bytes)
(10) Multiprocessors, (128) CUDA Cores/MP: 1280 CUDA Cores
GPU Max Clock rate: 1759 MHz (1.76 GHz)
Memory Clock rate: 4004 Mhz
Memory Bus Width: 192-bit
L2 Cache Size: 1572864 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
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: 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.0, CUDA Runtime Version = 9.0, NumDevs = 1
Result = PASS

注意到最後有個pass,說明安裝成功了!

10.最後在 ~/.bashrc 裏再設置一下cuda的環境變量:

export PATH=/usr/local/cuda/binPATH:+:$PATHexportLDLIBRARYPATH=/usr/local/cuda/lib64 {LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc (讓其生效。)

11.相關的參考:
1:https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1704&target_type=deblocal
2:http://m.blog.csdn.net/qq_20836725/article/details/45917909
(這個版本里面是進入到命令行模式安裝的,其實最新的版本,cuda9.0是不需要的)
3:http://blog.csdn.net/u012235003/article/details/54575758
4:https://www.cnblogs.com/upright/p/4982319.html
5:http://developer.download.nvidia.com/compute/cuda/7.5/Prod/docs/sidebar/CUDA_Installation_Guide_Linux.pdf
6:https://ju.outofmemory.cn/entry.38690(這篇博客給了我很大的啓發,ubuntu17.04+nvidia gtx 1080+cuda 9.0+)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章