在 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.
...
以下是有关我的硬件的一些信息(据我所知,笔记本电脑是联想 P15S Gen1)
# 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
目前我正在使用英特尔 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
)。
因为Nmath 的评论,睡了一夜之后,我检查了我的工作站,它也运行着带有 1080 Ti GPU 的 Ubuntu 20.04,其内核正在与 Nvidia 驱动程序配合使用。就我而言,目前是内核版本5.11.0-40-generic
。启动到此内核后,我删除了通过主线应用程序安装的所有较新内核。下次重启后,我通过命令安装了最新的 NVidia 驱动程序sudo apt install nvidia-driver-495
。这次驱动程序安装没有问题,因为原始内核是使用 glibc 2.31 构建的。
之后,我启动后出现黑屏。我通过Ctrl+ Alt+切换到终端F2。进入终端后,我通过 备份了我的 xorg.conf 文件sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
,并确保 nvidia 驱动程序未被列入/etc/modprobe.d/
和 的黑名单/lib/modprobe.d/
。最后,我通过 切换sudo prime-select intel
到英特尔驱动程序,然后通过sudo prime-select nvidia
切换回 nvidia 驱动程序。再次重启后,它就正常工作了。