天天看點

ubuntu正确安裝顯示卡驅動的姿勢重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)

避免sudo apt-get install nvidia-*安裝方式造成登入界面循環。

  1. ubuntu 16.04預設安裝了第三方開源的驅動程式nouveau,安裝nvidia顯示卡驅動首先需要禁用nouveau,不然會碰到沖突的問題,導緻無法安裝nvidia顯示卡驅動。

編輯檔案blacklist.conf

sudo vim /etc/modprobe.d/blacklist.conf
           

若未安裝vim則sudo apt-get install vim安裝或使用vi

在檔案最後部分插入以下兩行内容

blacklist nouveau
options nouveau modeset=0
           

更新系統

sudo update-initramfs -u
           

重新開機系統(一定要重新開機)

重新開機系統(一定要重新開機)

重新開機系統(一定要重新開機)

驗證nouveau是否已禁用

lsmod | grep nouveau
           
ubuntu正确安裝顯示卡驅動的姿勢重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)

沒有資訊顯示,說明nouveau已被禁用,接下來可以安裝nvidia的顯示卡驅動。

  1. 在英偉達的官網上查找你自己電腦的顯示卡型号然後下載下傳相應的驅動。網址:http://www.nvidia.cn/page/home.html
    ubuntu正确安裝顯示卡驅動的姿勢重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)
    ubuntu正确安裝顯示卡驅動的姿勢重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)

我下載下傳的版本:NVIDIA-Linux-x86_64-418.43.run(注意不同的版本最後安裝執行的具體選項不同)

下載下傳後的run檔案拷貝至home目錄下。

  1. 在ubuntu下按ctrl+alt+f1進入指令行界面,

然後在指令行界面下輸入:

su root                   //此處切換成root使用者,大有妙處,照做就行
	service lightdm stop      //這個是關閉圖形界面,不執行會出錯。
           

然後解除安裝掉原有驅動:

apt-get remove nvidia-*  (若安裝過其他版本或其他方式安裝過驅動執行此項)
           
  1. 給驅動run檔案賦予執行權限:
chmod  a+x NVIDIA-Linux-x86_64-418.43.run
           

安裝:

./NVIDIA-Linux-x86_64-418.43.run -no-x-check -no-nouveau-check -no-opengl-files //隻有禁用opengl這樣安裝才
     不會出現循環登陸的問題
           

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

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

-no-opengl-files:隻安裝驅動檔案,不安裝OpenGL檔案

安裝過程中的選項:(這是copy别人的,自己的沒記住,我也是嘗試選擇了好多遍才安裝好)

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

Would you like to register the kernel module souces 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 繼續

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

  1. 挂載Nvidia驅動:
modprobe nvidia
           

檢查驅動是否安裝成功:

nvidia-smi

如果出現如下提示,則說明安裝成功:

ubuntu正确安裝顯示卡驅動的姿勢重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)重新開機系統(一定要重新開機)

上圖是在圖形界面下補充的,在ctrl+alt+f1指令行模式下執行nvidia-smi指令喜愛顯示的資訊與上圖類似。

  1. 安裝過程中出現的錯誤及解決

錯誤1.

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.
           

遇到此問題,可以安裝後面正文的方法,重新嘗試安裝,

還有一個類似于此的錯誤,也是ERROR後面一大堆,但是kernel module後面是“nvidia-drm”,此問題是由于之前安裝過驅動的殘留所緻,請參考第3步後重新安裝。

錯誤2. 在安裝的最後一步,沒有提示安裝成功,而是顯示

出現這個問題最有可能的原因是你安裝的Ubuntu是UEFI模式啟動的,但是在BIOS中卻打開了Security BOOT選項。 正确做法是禁用該選項,具體方式請百度(我就是這一步折騰的我,其實一直沒有找到具體原因)

https://blog.csdn.net/xunan003/article/details/81665835