Ubuntu 22.04 + nvidia 驱动程序不工作

Ure*_*uri 5 nvidia drivers 22.04

我有一台联想 Z70-80,并将 Ubuntu 从 v20.04 升级到 v22.04。

升级时显示正在下载最新的nvidia-drivers-525,但无法安装。需要注意的是,我有

产品:GM108M [GeForce 840M] 供应商:NVIDIA Corporation

每当我尝试使用以下命令安装驱动程序时:

sudo apt install nvidia-driver-525 nvidia-dkms-525
Run Code Online (Sandbox Code Playgroud)

它抛出以下错误:

user@Lenovo-Z70-80:~$ sudo apt install nvidia-driver-525 nvidia-dkms-525
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nvidia-dkms-525 is already the newest version (525.60.11-0ubuntu0.22.04.1).
nvidia-driver-525 is already the newest version (525.60.11-0ubuntu0.22.04.1).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up nvidia-dkms-525 (525.60.11-0ubuntu0.22.04.1) ...
update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
Removing old nvidia-525.60.11 DKMS files...
Deleting module nvidia-525.60.11 completely from the DKMS tree.
Loading new nvidia-525.60.11 DKMS files...
Building for 5.15.0-56-generic
Building for architecture x86_64
Building initial module for 5.15.0-56-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-source-525.0.crash'
Error! Bad return status for module build on kernel: 5.15.0-56-generic (x86_64)
Consult /var/lib/dkms/nvidia/525.60.11/build/make.log for more information.
dpkg: error processing package nvidia-dkms-525 (--configure):
 installed nvidia-dkms-525 package post-installation script subprocess returned error exit status 10
dpkg: dependency problems prevent configuration of nvidia-driver-525:
 nvidia-driver-525 depends on nvidia-dkms-525 (<= 525.60.11-1); however:
  Package nvidia-dkms-525 is not configured yet.
 nvidia-driver-525 depends on nvidia-dkms-525 (>= 525.60.11); however:
  Package nvidia-dkms-525 is not configured yet.

dpkg: error processing package nvidia-driver-525 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for initramfs-tools (0.140ubuntu13.1) ...
update-initramfs: Generating /boot/initrd.img-5.15.0-56-generic
I: The initramfs will attempt to resume from /dev/sda9
I: (UUID=b839824a-2800-4868-b38c-064d54ed0eb9)
I: Set the RESUME variable to override this.
Errors were encountered while processing:
 nvidia-dkms-525
 nvidia-driver-525
E: Sub-process /usr/bin/dpkg returned an error code (1)

Run Code Online (Sandbox Code Playgroud)

命令nvidia-smi给出以下输出

NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
Run Code Online (Sandbox Code Playgroud)

谁能告诉我还可以做些什么来安装最新的驱动程序并使其正常工作?

谢谢。

mkt*_*lus 4

就我而言,问题是 GCC 编译器版本错误。我是这样发现的:

  1. 从https://www.nvidia.com/Download/index.aspx?lang=en-us下载安装程序

  2. 运行安装程序

  3. 当安装程序失败时,它会在 /var/log/nvidia-installer.log 下创建日志。阅读日志发现错误:

    warning: the compiler differs from the one used to build the kernel
      The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-3ubuntu1) 12.2.0
      You are using:           cc (Ubuntu 10.4.0-5ubuntu2) 10.4.0
    
    Warning: Compiler version check failed:
    
    The major and minor number of the compiler used to
    compile the kernel:
    
    x86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-3ubuntu1) 12.2.0, GNU ld (GNU Binutils for Ubuntu) 2.39
    
    does not match the compiler used here:
    
    cc (Ubuntu 10.4.0-5ubuntu2) 10.4.0
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    
    It is recommended to set the CC environment variable
    to the compiler that was used to compile the kernel.
    
    Run Code Online (Sandbox Code Playgroud)

根据错误,在我的系统配置中将 GCC 版本更改回 12 并运行命令:

sudo apt install nvidia-driver-525
Run Code Online (Sandbox Code Playgroud)

导致安装成功。


小智 1

删除所有 nvidia 软件包...然后更新内核...

sudo update-initramfs -u
Run Code Online (Sandbox Code Playgroud)

重启...

再次安装驱动:

sudo apt install nvidia-driver-525
Run Code Online (Sandbox Code Playgroud)

(不要添加任何其他东西)

之后应该可以工作了...特别注意 initramfs 是否构建并完成。如果没有,您必须再次手动重建它,否则机器可能无法启动。