Asus主機 i7 Ubuntu16.04 + GTX 1080 8G + cuda10.0 + cudnn7.4.1 install driver

Asus主機 i7 Ubuntu16.04 + GTX 1080 8G install driver

目錄

Install CUDA10.0 Reference

Step1. 先update and upgrade 一下

$ sudo apt-get update
$ sudo apt-get upgrade

Step2. follow 2.6 去nvidia cuda download

  • 選擇 Linux -> x86_64 -> Ubuntu -> 16.04 ->deb(network選比較小的覺得速度較快哈 )
$ `sudo dpkg -i cuda-repo-ubuntu1604_10.0.130-1_amd64.deb`
$ `sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub`
 
 When installing using network repo on Ubuntu 17.10: 
 $ sudo apt-key adv --fetch-keys https:/...  
 When installing using network repo on Ubuntu 16.04:
 $ sudo apt-key adv --fetch-keys http:/...
 Ubuntu 17.10 跟 16.04 路徑只差 https 跟 http!!!
$ `sudo apt-get update`
$ `sudo apt-get install cuda`

Step3. follow 3.7.2 Package_Upgrades

$ sudo apt-get install cuda-drivers  

Step4. follow 7.1.1 Environment Setup

$ export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
$ export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64\
                        ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Step5. follow 7.3.1 install Third-party Libraries

(不確定需不需要,都裝@@)
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev \
libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

Step6. follow 2.1 Verify you have a CUDA-Capable GPU

lspci | grep -i nvidia  
follow 2.4
sudo apt-get install linux-headers-$(uname -r)

Step7. 檢查一些相關...

$ lspci 
$ dmesg
$ lsmod 

Step8. follow 4.3.5 Ubuntu Disabling Nouveau

created the file:
$ sudo vim /etc/modprobe.d/blacklist-nouveau.conf
(加入以下) 
blacklist nouveau
options nouveau modeset=0  
$ sudo update-initramfs -u

Step9. follow 這篇網誌 把path 放到 /etc/profile,(開機就會打開)

$ sudo vim /etc/profile
(加入以下) 
export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64\
                      ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 

Step10. 重開機吧~~~~~~

Step11. (如果開機還能用就繼續 step 11. 執行 Test samples)

follow 7.2.2 install Writeable Samples,會在home下產生 /NVIDIA_CUDA-10.0_Samples
$ `cuda-install-samples-10.0.sh .`

Step12. follow 7.2.3.1 Verify the Driver Version

$ cat /proc/driver/nvidia/version
$ nvcc -V 
$ cd NVIDIA_CUDA-10.0_Samples 
$ cat /proc/cpuinfo ->可以看到電腦幾核心
$ make -j  or (make -j8 電腦8核

Step13. follow 7.2.3.3 Running the Binaries

$ cd ~/NVIDIA_CUDA-10.0_Samples/bin/x86_64/linux/release
$ ./deviceQuery 

$ ./bandwidthTest 
 
 
 
 
 
 

 

 

Install cuDNN7.4.1 Reference



dpkg tips

dpkg -i package.deb     #安装包
dpkg -r package         #删除包
dpkg -P package         #删除包(包括配置文件)
dpkg -L package         #列出与该包关联的文件
dpkg -l package         #显示该包的版本
dpkg --unpack package.deb  #解开deb包的内容
dpkg -S keyword            #搜索所属的包内容
dpkg -l                    #列出当前已安装的包
dpkg -c package.deb        #列出deb包的内容
dpkg --configure package   #配置包

Step1. 到官網download

要註冊才能下載!
follow 2.3. Installing cuDNN on Linux
 











解壓縮資料夾
$ tar -xzvf cudnn-10.0-linux-x64-v7.4.1.5.tgz

Step2. 去到解壓縮的資料夾裡

解壓縮的資料夾/cuda 裡面還有兩個資料夾
/cuda/lib64/
/cuda/include/
複製裏面資料到 local/cuda 裏面
$ cd ../cuda/lib64
$ sudo cp ./* /usr/local/cuda/lib64/
$ cd ../cuda/include
$ sudo cp cudnn.h /usr/local/cuda/include/
更新他們的軟連結
$ cd /usr/local/cuda/lib64/
$ sudo rm -rf libcudnn.so libcudnn.so.7
$ sudo ln -s libcudnn.so.7.4.1 libcudnn.so.7
$ sudo ln -s libcudnn.so.7 libcudnn.so

Step3. 檢查cudnn 安裝成功與否

 

 

 

 

 

 

 

 


安裝:
$ sudo dpkg -i libcudnn7-doc_7.4.1.5-1+cuda10.0_amd64.deb
查安裝路徑:
$ sudo dpkg -c libcudnn7-doc_7.4.1.5-1+cuda10.0_amd64.deb
查到 /mnistCUDNN 的完整路徑在
/usr/src/cudnn_samples_v7/mnistCUDNN
$ cd /usr/src/cudnn_samples_v7/mnistCUDNN


follow 2.4. Verifying 
-------------------------------------------
因為這路徑下是unwritable path.所以複製到可讀寫的路徑
$ `cp -r /usr/src/cudnn_samples_v7/ .`
$ `cd  ./cudnn_samples_v7/mnistCUDNN`
編譯:
$ make clean & make -j (or make -j8
執行:
$ ./mnistCUDNN


**如果直接在/usr/src/cudnn_samples_v/ 編譯&執行有error發生** 
有可能會跑出下列錯誤
./mnistCUDNN: error while loading shared libraries: libcudart.so.8.0:
cannot open shared object file: No such file or directory
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

看一下安裝之後

$ nvidia-smi
Wed Dec  5 14:36:14 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.79       Driver Version: 410.79       CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| 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 1080    Off  | 00000000:01:00.0  On |                  N/A |
|  0%   36C    P8     9W / 198W |    378MiB /  8116MiB |      1%      Default |
+-------------------------------+----------------------+----------------------+
                                                                              
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1124      G   /usr/lib/xorg/Xorg                           218MiB |
|    0      2044      G   compiz                                       155MiB |
|    0     19569      G   /usr/lib/firefox/firefox                       2MiB |
+-----------------------------------------------------------------------------+

留言