核心為 5.15 的 Ubuntu 20.04 - 如何安裝 NVidia 驅動程式?

核心為 5.15 的 Ubuntu 20.04 - 如何安裝 NVidia 驅動程式?

在 Ubuntu 20.04 上安裝具有更新核心的 NVidia 驅動程式的建議方法是什麼?透過 apt 安裝不起作用。我在安裝結束時收到以下錯誤

# sudo apt install nvidia-driver-495 -y
...
...
Building for 5.15.1-051501-generic
Building for architecture x86_64
Building initial module for 5.15.1-051501-generic
ERROR (dkms apport): kernel package linux-headers-5.15.1-051501-generic is not supported
Error! Bad return status for module build on kernel: 5.15.1-051501-generic (x86_64)
Consult /var/lib/dkms/nvidia/495.44/build/make.log for more information.
dpkg: error processing package nvidia-dkms-495 (--configure):
 installed nvidia-dkms-495 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-495:
 nvidia-driver-495 depends on nvidia-dkms-495 (<= 495.44-1); however:
  Package nvidia-dkms-495 is not configured yet.
 nvidia-driver-495 depends on nvidia-dkms-495 (>= 495.44); however:
  Package nvidia-dkms-495 is not configured yet.

dpkg: error processing package nvidia-driver-495 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
...

這是我的硬體的一些資訊(筆記型電腦是 Lenovo P15S Gen1 AFAIK)

# uname -r
5.15.1-051501-generic

# lspci | grep -E "VGA|3D"
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics (rev 02)
2d:00.0 3D controller: NVIDIA Corporation GP108GLM [Quadro P520] (rev a1)

# lscpu | grep -i model
Model name:                      Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Model:                           142

目前,我正在使用 Intel GPU,這很好,但我真的不想經常隨身攜帶專用的 NVidia GPU而不使用它。

看看/var/lib/dkms/nvidia/495.44/build/make.log我在文件末尾有這個

/var/lib/dkms/nvidia/495.44/build/nvidia/nv-dma.c:976: warning: "IMPORT_SGT_STUBS_NEEDED" redefined
  976 | #define IMPORT_SGT_STUBS_NEEDED 0
      | 
/var/lib/dkms/nvidia/495.44/build/nvidia/nv-dma.c:970: note: this is the location of the previous definition
  970 | #define IMPORT_SGT_STUBS_NEEDED 1
      | 
/var/lib/dkms/nvidia/495.44/build/nvidia/nv-mmap.c: In function ‘nv_encode_caching’:
/var/lib/dkms/nvidia/495.44/build/nvidia/nv-mmap.c:334:16: warning: this statement may fall through [-Wimplicit-fallthrough=]
  334 |             if (NV_ALLOW_CACHING(memory_type))
      |                ^
/var/lib/dkms/nvidia/495.44/build/nvidia/nv-mmap.c:337:9: note: here
  337 |         default:
      |         ^~~~~~~
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-cray.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-cray.o'
make[2]: *** Waiting for unfinished jobs....
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-i2c.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-i2c.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-p2p.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-p2p.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-mmap.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-mmap.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-pci.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-pci.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-dma.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-dma.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv-acpi.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv-acpi.o'
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by scripts/basic/fixdep)
scripts/basic/fixdep: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by scripts/basic/fixdep)
make[2]: *** [scripts/Makefile.build:277: /var/lib/dkms/nvidia/495.44/build/nvidia/nv.o] Error 1
make[2]: *** Deleting file '/var/lib/dkms/nvidia/495.44/build/nvidia/nv.o'
make[1]: *** [Makefile:1874: /var/lib/dkms/nvidia/495.44/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.15.1-051501-generic'
make: *** [Makefile:80: modules] Error 2

我對老司機也有同樣的問題。看來主線核心要求 glibc 至少是 v2.33,目前僅在 Ubuntu 21.04 中可用。

答案1

這是解決方案。正如我們從我的帖子中看到的,make.log 檔案顯示需要 glibc >= 2.33,但 Ubuntu 20.04 使用 glibc 2.31 ( ldconfig --version)。

因為數學的在評論並睡了一夜後,我檢查了我的工作站,它也運行帶有 1080 Ti GPU 的 Ubuntu 20.04,該核心正在與 Nvidia 驅動程式一起工作。就我而言,目前它是核心版本5.11.0-40-generic。啟動到這個核心後,我刪除了透過主線應用程式安裝的所有較新的核心。下次重新啟動後,我透過sudo apt install nvidia-driver-495命令安裝了最新的 NVidia 驅動程式。這次驅動程式安裝工作沒有問題,因為原始核心是使用 glibc 2.31 建構的。

之後我啟動後出現黑畫面。我透過 ++Ctrl切換到終端。進入終端後,我透過備份 xorg.conf 檔案並確保 nvidia 驅動程式沒有被列入 和 中的黑名單。最後我切換到 intel 驅動程序,然後又切換回 nvidia 驅動程式。再次重啟後就成功了。AltF2sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak/etc/modprobe.d//lib/modprobe.d/sudo prime-select intelsudo prime-select nvidia

答案2

雖然透過apt倉庫安裝失敗,但是透過官方驅動頁面安裝是可以的

  1. 從中選擇合適的驅動程式這裡
  2. (如果您使用安全啟動)請使用給定的安裝說明這裡
  3. 重新啟動系統並輸入為將驅動程式註冊到 MOK 而建立的密碼

相關內容