尝试安装 nividia 驱动程序时检测到系统问题,系统随机冻结

尝试安装 nividia 驱动程序时检测到系统问题,系统随机冻结

我是 Linux 新手,我刚刚安装了 Ubuntu 22.04.2 和一些其他东西,比如 Docker 和一些 jetbrains IDE,但除此之外,这是一个相对干净的安装

它经常随机冻结(通常需要 1-2 分钟才能完全恢复并可用,整个计算机冻结,鼠标、键盘、屏幕,甚至按 alt+F2 也没有任何反应)所以我认为这是我没有为我的 3070 Tuff 卡安装任何 nividia 驱动程序。

$ uname -a
Linux Desktop-MOON 5.19.0-42-generic #43~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 21 16:51:08 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ inxi -G
Graphics:
  Device-1: NVIDIA GA104 [GeForce RTX 3070] driver: nouveau v: kernel
  Display: wayland server: X.Org v: 1.22.1.1 with: Xwayland v: 22.1.1
    compositor: gnome-shell v: 42.5 driver: gpu: nouveau
    resolution: 3840x1080~60Hz
  OpenGL: renderer: llvmpipe (LLVM 15.0.7 256 bits) v: 4.5 Mesa 22.2.5

我正在按照此页面上的说明进行操作:https://help.ubuntu.com/community/NvidiaDriversInstallation

cat /proc/driver/nvidia/version 返回:cat /proc/driver/nvidia/version: No such file or directory

sudo ubuntu-drivers list 返回:

nvidia-driver-470, (kernel modules provided by linux-modules-nvidia-470-generic-hwe-22.04)
nvidia-driver-525-open, (kernel modules provided by linux-modules-nvidia-525-open-generic-hwe-22.04)
nvidia-driver-470-server, (kernel modules provided by linux-modules-nvidia-470-server-generic-hwe-22.04)
nvidia-driver-510, (kernel modules provided by linux-modules-nvidia-510-generic-hwe-22.04)
nvidia-driver-515, (kernel modules provided by linux-modules-nvidia-515-generic-hwe-22.04)
nvidia-driver-530-open, (kernel modules provided by linux-modules-nvidia-530-open-generic-hwe-22.04)
nvidia-driver-525, (kernel modules provided by linux-modules-nvidia-525-generic-hwe-22.04)
nvidia-driver-515-open, (kernel modules provided by nvidia-dkms-515-open)
nvidia-driver-530, (kernel modules provided by linux-modules-nvidia-530-generic-hwe-22.04)
nvidia-driver-525-server, (kernel modules provided by linux-modules-nvidia-525-server-generic-hwe-22.04)
nvidia-driver-515-server, (kernel modules provided by linux-modules-nvidia-515-server-generic-hwe-22.04)

sudo ubuntu-drivers install 返回:

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 413, in install
    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

并弹出“检测到系统程序问题”消息

我该如何阻止我的系统频繁冻结以及如何安装 nividia 驱动程序?

答案1

代码中似乎有一个错误。由于这是一个 Python 脚本,因此您应该能够自行修复它:

您需要以“sudo”执行 nano 或 vi 来编辑/usr/lib/python3/dist-packages/UbuntuDrivers/detect.py

进攻线是835。

找到以下行:

version = int(package_name.split('-')[-1])

修改为:

version = int(package_name.split('-')[2])

并重试。更多文档可参阅这里

相关内容