ubuntu16.04——NVIDIA驅動安裝(親測好使!+避坑)


1、查看顯卡型號

$ lshw -c video

  結果顯示:

  

  可以看到你的顯卡信息,比如我的就是 product: GF108GL[Quadro 600] 

  或

$ lspci | grep VGA 01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)

2、下載驅動程序:

  http://www.nvidia.cn/Download/index.aspx

  下載完之后是一個名稱為 NVIDIA-Linux-x86_64-xxx.xx.run 的文件。可以用chmod +x 增加執行許可權執行。

  

 

  為了再次確認一遍,你還可以使用這個命令查看你可以使用的驅動:

$ ubuntu-drivers devices

  結果顯示:

  如果結果顯示和搜索到的驅動版本一樣,推薦也是390.67,那我們可以安心安裝390.67版本。但是結果顯示的並沒有390.67,為了避免出錯,建議選擇結果顯示中的版本號,如361。

  

 

  接着需要先安裝一些 NVIDIA 顯卡依賴的軟件,在終端依次執行如下命令:

$ sudo dpkg --add-architecture i386 $ sudo apt update $ sudo apt install build-essential libc6:i386

3、刪除原有驅動:(可選)

$ sudo apt-get remove --purge nvidia*

4、禁用nouveau驅動:

  這一步必須,不禁用nvidia驅動安不上。

  編輯/etc/modprobe.d/blacklist-nouveau.conf 檔案,新增以下內容

blacklist nouveau blacklist lbm-nouveau options nouveau modeset=0 alias nouveau off alias lbm-nouveau off

  然后儲存。

sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"

  關閉nouveau:

$ echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf

  然后重啟:

$ sudo update-initramfs -u $ sudo reboot

  驗證是否禁用nouveau:

lsmod | grep nouveau

  沒有信息返回說明已禁用(如圖)

  

 

5、獲取Kernel source(非常重要):

$ sudo apt-get install linux-source $ apt-get install linux-headers-x.x.x-genneric $ sudo apt-get install linux-headers-$(uname -r)

6、先按Ctrl + Alt + F1到控制台,關閉當前圖形環境

$ sudo service lightdm stop

7、安裝Nvidia驅動:

chmod +x NVIDIA-Linux-x86_64-xxx.xx.run sudo ./NVIDIA-Linux-x86_64-xxx.xx.run sudo ./NVIDIA-Linux-x86_64-396.18.run -no-x-check -no-nouveau-check -no-opengl-files

  //只有禁用opengl這樣安裝才不會出現循環登陸的問題

    -no-x-check:安裝驅動時關閉X服務

    -no-nouveau-check:安裝驅動時禁用nouveau

    -no-opengl-files:只安裝驅動文件,不安裝OpenGL文件

8、安裝過程中的選項:

  The distribution-provided pre-install script failed! Are you sure you want to continue? 選擇 yes 繼續。

  Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later?  選擇 No 繼續。

  問題沒記住,選項是:install without signing

  問題大概是:Nvidia's 32-bit compatibility libraries? 選擇 No 繼續。

  Would you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used when you restart x? Any pre-existing x confile will be backed up.  選擇 Yes程中會有一些問題,自己回答選擇Yes或者No。

  這些選項如果選擇錯誤可能會導致安裝失敗,沒關系,只要前面不出錯,多嘗試幾次就好。

  如果出現安裝錯誤

An NVIDIA kernel module ‘nvidia-drm’ appears to already be loaded in your kernel…

 

  那么就輸入這一行代碼

sudo systemctl isolate multi-user.target sudo modprobe -r nvidia-drm

9、打開圖形界面:

sudo service lightdm start

  然后掛在Nvidia驅動

$ modprobe nvidia

10、檢查驅動是否安裝成功

  說明驅動安裝成功 

  下面也可以測試

sudo lshw -c video|grep configuration configuration: driver=nvidia latency=0

11、參考鏈接

https://www.itread01.com/content/1546829642.html

https://blog.csdn.net/yaohuan2017/article/details/108670724

https://zhuanlan.zhihu.com/p/59618999

https://blog.csdn.net/qiancaobaicheng/article/details/95096354

12、注意!!!

  如果出現問題:

ERROR: Unable to load the kernel module 'nvidia.ko'. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb/nvidiafb is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s), or NVIDIA GPU installed in this system is not supported by this NVIDIA Linux graphics driver release.

  可能是沒有禁用安全引導項


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM