首先介紹一下筆者的電腦:
CPU : I7-11700
Board : msi mpg-z490
GPU: GTX 1660 super
SSD :512G SSD *2
HDD : 1TB
先說說筆者裝系統踩到的坑,第一個就是不知道是什麼問題,ubuntu 16.04 和18.04 通通裝不上去,只能用20.04,然後就遇到第一個坑了,這主機板安裝20.04 竟然沒辦法識別有線網路,上網查詢之後發現原來ubuntu 正式板驅動還未更新到這張板子,所以必須先用開發者版本的kernal , 安裝make和build套件,再降到正式kernal安裝驅動,才有網路可以使用.....
-----以上純屬廢話----
-----以下正文開始----
刪除所有已安裝的nvidia驅動、cuda、cudnn
sudo apt remove nvidia-cuda-toolkit
sudo apt-get remove *nvidia*
sudo apt-get purge *nvidia*
sudo apt-get remove libnvidia*
sudo apt-get purge libnvidia*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*
禁用nouveau 驅動
sudo gedit /etc/modprobe.d/blacklist.conf
輸入以下內容保存
blacklist nouveau
options nouveau modeset=0
更新系統和重開機
sudo update-initramfs -u
sudo reboot
查看是否禁用成功(無輸出代表禁用成功)
lsmod | grep nouveau
安裝NVIDIA驅動(450版本)
下載nvidia 驅動(注意須下載450版本,460不支援cuda11.0)
安裝驅動並檢查
sudo ./NVIDIA-Linux-x86_64–450.119.03.run
nvidia-smi
安裝CUDA
下載CUDA 11.0
sudo ./cuda_11.0.2_450.51.06_linux.run
成功之後會看到以下內容
driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.0/
Samples: Installed in /home/itts-ai/Please make sure that
— PATH includes /usr/local/cuda-11.0/bin
— LD_LIBRARY_PATH includes /usr/local/cuda-11.0/lib64, or, add /usr/local/cuda-11.0/lib64 to /etc/ld.so.conf and run ldconfig as rootTo uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.0/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least .00 is required for CUDA 11.0 functionality to work.
To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file:
sudo <CudaInstaller>.run — silent — driverLogfile is /var/log/cuda-installer.log
添加環境變數
nano ~/.bashrc
在最下面新增以下內容
export PATH=”/usr/local/cuda-11.0/bin:$PATH”
export LD_LIBRARY_PATH=”/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH”
更新
source ~/.bashrc
檢查cuda 安裝
nvcc -V
安裝CUDNN
下載cudnn 8.0.5.39 ,此處需要新建/登入NVIDIA會員
https://developer.nvidia.com/feedback/ws-gpu-2021-04
下載請選擇cudnn_Library_for_linux[x86_64]
解壓並將相關檔案移至cuda 資料夾
tar -xzvf cudnn-11.0-linux-x64-v8.0.5.39.tgz
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
大功告成