在 Ubuntu 22.04 上安装 NVIDIA 驱动程序

在 Ubuntu 22.04 上安装 NVIDIA 驱动程序

我按照许多教程在 Ubuntu 22.04 上安装 NVIDIA 驱动程序,但到目前为止都没有成功。在更新之前,在 Ubuntu 20.04 上,一切正常。

我也尝试过通过 GUI 和控制台安装驱动程序。在控制台中,我尝试通过运行以下命令安装 nvidia-driver-525、nvidia-driver-470 和 nvidia-driver-515-open 版本

sudo apt install [driver version]

我有 RTX2080Ti。

如果我运行sudo ubuntu-drivers autoinstall,我会收到以下错误:

dpkg: warning: version 'unsigned-5.18.10-051810' has bad syntax: version number does not start with digit
dpkg: warning: version 'unsigned-5.18.10-051810' has bad syntax: version number does not start with digit
dpkg: warning: version 'unsigned-5.18.10-051810' has bad syntax: version number does not start with digit
dpkg: warning: version 'unsigned-5.18.10-051810' has bad syntax: version number does not start with digit
Traceback (most recent call last):
  File "/usr/bin/ubuntu-drivers", line 513, in <module>
    greet()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/bin/ubuntu-drivers", line 432, in autoinstall
    command_install(config)
  File "/usr/bin/ubuntu-drivers", line 187, in command_install
    UbuntuDrivers.detect.nvidia_desktop_pre_installation_hook(to_install)
  File "/usr/lib/python3/dist-packages/UbuntuDrivers/detect.py", line 839, in nvidia_desktop_pre_installation_hook
    with_nvidia_kms = version >= 470
UnboundLocalError: local variable 'version' referenced before assignment

非常感谢您的帮助。

答案1

假设这是一个全新安装并在 Xorg 上登录 Ubuntu(从登录中的设置图标)

请执行下列操作:

sudo apt update && apt upgrade -y

只是为了获得任何更新,然后从这个 github 页面https://github.com/lutris/docs/blob/master/InstallingDrivers.md

以下命令用于安装 nvidia 驱动程序(版本 515***;将其更改为 nvidia 卡的最新版本;有关更多信息,请参阅页面)

sudo add-apt-repository ppa:graphics-drivers/ppa && sudo dpkg --add-architecture i386 && sudo apt update && sudo apt install -y nvidia-driver-515 libvulkan1 libvulkan1:i386

然后重新启动

reboot

希望这有效,并检查以确保您的操作系统能够识别您的 GPU。

相关内容