ubuntu-drivers for 22.04 crashes while attempting to detect nvidia gpu

Bug #1997484 reported by Scott Griffith
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-drivers-common (Ubuntu)
New
Undecided
Unassigned

Bug Description

SYSTEM INFORMATION:
user@host# lsb_release -rd
Description: Ubuntu 22.04.1 LTS
Release: 22.04

PACKAGE VERSION INFORMATION:
user@host# apt-cache policy ubuntu-drivers-common
ubuntu-drivers-common:
  Installed: 1:0.9.6.1
  Candidate: 1:0.9.6.1
  Version table:
 *** 1:0.9.6.1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status

EXPECTED RESULT:
Any updated/missing drivers are upgraded/installed

ACTUAL RESULT:
when using the command 'nvidia-drivers install' after a fresh installation, the following error is produced from Python3:
==================================================================================================
user@hostname:~$ 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

==================================================================================================
FIX FOR THIS BUG/WORK AROUND:
This is fixed by adding the following code on line 830:
    version = 0

<CODE SNIPPET>
def nvidia_desktop_pre_installation_hook(to_install):
    '''Applies changes that need to happen before installing the NVIDIA drivers'''
    with_nvidia_kms = False
    version = 520

        # Enable KMS if nvidia >= 470
    for package_name in to_install:
        if package_name.startswith('nvidia-driver-'):
            try:
                version = int(package_name.split('-')[-1])
            except ValueError:
                pass
            finally:
                with_nvidia_kms = version >= 470

    if with_nvidia_kms:
        set_nvidia_kms(1)

</CODE SNIPPET>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.