我尝试根据此帖子安装 Nvidia 驱动程序 304.317: 无法在 Ubuntu 18.04 上安装 Nvidia 驱动程序
安装过程中,出现了几个错误:
错误消息 1:
ERROR: Failed to run '/usr/sbin/dkms build -m nvidia -v 304.137 -k 5.0.0-23-generic':
Kernel preparation unnecessary for this kernel. Skipping ...
Building module:
cleaning build area...
make -j2 KERNELRELEASE=5.0.0-23-generic module SYSSRC=/lib/modules/5.0.0-23-generic/build...................(bad exit status: 2)
ERROR (dkms apport): binary package for nvidia: 304.137 not found
Error! Bad return status for module build on kernel: 5.0.0-23-generic (i686)
Consult /var/lib/dkms/nvidia/304.137/build/make.log for more information.
错误消息2:
ERROR: Failed to install the kernel module through DKMS.
No kernel module was installed: please try to installing again without DKMS, or check the DKMS logs for more information.
错误消息 3:
ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log for details.
You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.
nvidia-安装程序.log
nvidia-installer log file '/var/log/nvidia-installer.log'
creation time: Sat Aug 10 21:13:58 2019
installer version: 304.137
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
nvidia-installer command line:
./nvidia-installer
Unable to load: nvidia-installer ncurses v6 user interface
Using: nvidia-installer ncurses user interface
-> License accepted.
-> Installing NVIDIA driver version 304.137.
-> Running distribution scripts
executing: '/usr/lib/nvidia/pre-install'...
-> done.
-> The distribution-provided pre-install script failed! Continue installation anyway? (Answer: 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. (Answer: Yes)
-> Installing both new and classic TLS OpenGL libraries.
-> Searching for conflicting X files:
-> done.
-> Searching for conflicting OpenGL files:
-> done.
-> Installing 'NVIDIA Accelerated Graphics Driver for Linux-x86' (304.137):
executing: '/sbin/ldconfig'...
executing: '/sbin/depmod -aq'...
depmod: WARNING: Ignored deprecated option -q
-> done.
-> Driver file installation is complete.
-> Installing DKMS kernel module:
ERROR: Failed to run `/usr/sbin/dkms build -m nvidia -v 304.137 -k 5.0.0-23-generic`:
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j2 KERNELRELEASE=5.0.0-23-generic module SYSSRC=/lib/modules/5.0.0-23-generic/build...................(bad exit status: 2)
ERROR (dkms apport): binary package for nvidia: 304.137 not found
Error! Bad return status for module build on kernel: 5.0.0-23-generic (i686)
Consult /var/lib/dkms/nvidia/304.137/build/make.log for more information.
-> error.
ERROR: Failed to install the kernel module through DKMS. No kernel module was installed; please try installing again without DKMS, or check the DKMS logs for more information.
ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.
生成日志
DKMS make.log for nvidia-304.137 for kernel 5.0.0-23-generic (i686)
Sa 10. Aug 21:14:49 CEST 2019
NVIDIA: calling KBUILD...
Makefile:223: ================= WARNING ================
Makefile:224: 'SUBDIRS' will be removed after Linux 5.3
Makefile:225: Please use 'M=' or 'KBUILD_EXTMOD' instead
Makefile:226: ==========================================
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
mkdir -p /var/lib/dkms/nvidia/304.137/build/.tmp_versions ; rm -f /var/lib/dkms/nvidia/304.137/build/.tmp_versions/*
make -f ./scripts/Makefile.build obj=/var/lib/dkms/nvidia/304.137/build
(cat /dev/null; echo kernel//var/lib/dkms/nvidia/304.137/build/nvidia.ko;) > /var/lib/dkms/nvidia/304.137/build/modules.order
[several compiler calls]
cc -Wp,-MD,/var/lib/dkms/nvidia/304.137/build/.os-interface.o.d -nostdinc -isystem /usr/lib/gcc/i686-linux-gnu/7/include -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -Iubuntu/include -include ./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror-implicit-function-declaration -Werror=implicit-int -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m32 -msoft-float -mregparm=3 -freg-struct-return -fno-pic -mpreferred-stack-boundary=2 -march=i686 -mtune=generic -Wa,-mtune=generic32 -ffreestanding -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -I/var/lib/dkms/nvidia/304.137/build -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"304.137\" -Wno-unused-function -Wuninitialized -UDEBUG -U_DEBUG -DNDEBUG -DMODULE -DKBUILD_BASENAME='"os_interface"' -DKBUILD_MODNAME='"nvidia"' -c -o /var/lib/dkms/nvidia/304.137/build/os-interface.o /var/lib/dkms/nvidia/304.137/build/os-interface.c
[several compiler warnings -Wsign-compare]
/var/lib/dkms/nvidia/304.137/build/os-interface.c: In function ‘os_get_current_time’:
/var/lib/dkms/nvidia/304.137/build/os-interface.c:667:5: error: implicit declaration of function ‘do_gettimeofday’; did you mean ‘efi_gettimeofday’? [-Werror=implicit-function-declaration]
do_gettimeofday(&tm);
^~~~~~~~~~~~~~~
efi_gettimeofday
[several compiler calls]
Makefile:1606: recipe for target '_module_/var/lib/dkms/nvidia/304.137/build' failed
make[2]: *** [_module_/var/lib/dkms/nvidia/304.137/build] Error 2
NVIDIA: left KBUILD.
nvidia.ko failed to build!
Makefile:262: recipe for target 'module' failed
make[1]: *** [module] Error 1
makefile:59: recipe for target 'module' failed
make: *** [module] Error 2
我尝试安装没有 dkms 的驱动程序,但遇到了同样的问题。nvidia 的 readme 无法帮助我。有什么建议吗?
编辑:
我安装了 16.04(这是我在硬盘崩溃前安装的),但遇到了同样的问题。无论我是使用 还是完全手动安装,都没有关系ubuntu-dirivers autoinstall
。apt-get install nvidia-304
如果我尝试安装以前的版本 304.135(实际是 304.137),也是如此。在我的硬盘崩溃之前,我使用的是 304.134 版本(因为 304.135 出现了一些问题),但似乎这个版本不再存在于存储库中。nouveau 驱动程序运行良好(适用于 16.04 和 18.04),甚至带有第二个屏幕,但性能很差。
更新
在对 Lubuntu 版本(16.04 和 18.04)和不同的 nvidia-304 版本进行多次测试和尝试后,我认为问题出在使用的编译器版本上,应该是 gcc-4.6(找不到链接了),16.04 使用 gcc-5.0,18.04 使用 gcc-7.4。由于工作量太大,我放弃安装专有驱动程序。
在研究过程中,我发现 nouveau 驱动程序从未安装在系统上。ubuntu-drivers autoinstall
无法安装 nouveau 驱动程序。我手动安装了(在 18.04 上)apt-get install xserver-xorg-video-nouveau
,安装后删除了以下软件包并且系统崩溃了:
lubuntu-desktop lubuntu-gtk-core lubuntu-gtk-desktop
xserver-xorg-core-hwe-18.04 xserver-xorg-input-all-hwe-18.04
xserver-xorg-input-libinput-hwe-18.04 xserver-xorg-input-synaptics-hwe-18.04
xserver-xorg-video-all-hwe-18.04 xserver-xorg-video-amdgpu-hwe-18.04
xserver-xorg-video-ati-hwe-18.04 xserver-xorg-video-fbdev-hwe-18.04
xserver-xorg-video-intel-hwe-18.04 xserver-xorg-video-nouveau-hwe-18.04
xserver-xorg-video-qxl-hwe-18.04 xserver-xorg-video-radeon-hwe-18.04
xserver-xorg-video-vesa-hwe-18.04 xserver-xorg-video-vmware-hwe-18.04
答案1
我会强烈推荐您可使用ubuntu-drivers
工具代替。它更安全,并且会安装合适的NVIDIA 或 nouveau您的卡的驱动程序。
但是,您需要先通过在终端中运行以下命令来清理并清除当前的 NVIDIA 驱动程序:
sudo apt purge nvidia-*
然后您可以像这样在终端中运行该工具:
sudo ubuntu-drivers autoinstall
然后重新启动系统以使更改生效。
注意:
304.* 不再受支持英伟达并且没有适用于较新内核的版本sudo ubuntu-drivers autoinstall
将安装该nouveau
驱动程序,我认为该驱动程序应该对这么旧的 GPU 有足够好的支持。
但是,如果你必须按照问题中描述的方式去做。你可能需要查看你的 BIOS 设置并禁用安全启动。来源
另一个选择是返回到 Ubuntu 16.04:
如果你选择这样做,你可能需要启用受限制的Ubuntu 存储库。您可以从 GUI 中的软件和更新选项执行此操作,也可以在终端中添加存储库,如下所示:
echo "deb http://security.ubuntu.com/ubuntu xenial-security main restricted" | sudo tee -a /etc/apt/sources.list
之后更新 apt 包列表:
sudo apt update
然后像这样安装驱动程序:
sudo ubuntu-drivers autoinstall
或者
sudo apt install nvidia-304
或者