Skip to content

[Bug]: Ubuntu driver scripts assume standard kernel version naming, breaking custom kernels #601

@jfernandez

Description

@jfernandez

Describe the bug

_resolve_kernel_version() in the Ubuntu nvidia-driver scripts assumes kernel versions follow Ubuntu's major.minor.patch-revision-flavor naming convention (e.g. 6.5.0-44-generic). Custom kernels built for Ubuntu that use non-standard version naming (e.g. 6.5.13custom-00004-g00fabdb6286a) are mangled into an incorrect version string, causing the driver build to fail because no matching linux-headers-* package exists.

The function extracts a version via regex from the Version: field and a flavor via sed 's/[^a-z]*//' from uname -r, then concatenates them. For non-standard kernels this produces a mangled, non-existent version. For example:

  • uname -r: 6.5.13custom-00004-g00fabdb6286a
  • Version regex extracts: 6.5.13-00004
  • Flavor regex extracts: custom-00004-g00fabdb6286a
  • Concatenated result: 6.5.13-00004-custom-00004-g00fabdb6286a (does not exist)
  • Correct value: 6.5.13custom-00004-g00fabdb6286a (matches uname -r exactly)

To Reproduce

  1. Run a kernel with a non-standard version string (e.g. a custom-built kernel using git-describe naming)
  2. Ensure the corresponding linux-headers-$(uname -r) package is available in the apt repository
  3. Run the gpu-driver-container. The driver build fails with "Could not resolve Linux kernel version"

Expected behavior

When linux-headers-${KERNEL_VERSION} already exists as a valid package for the exact uname -r output, the driver should use it as-is without attempting to decompose and reconstruct the version string.

Environment (please provide the following information):

  • gpu-driver-container source: HEAD of main
  • Host OS: Ubuntu 22.04
  • Kernel Version: Any non-standard naming (e.g. 6.5.13custom-00004-g00fabdb6286a)
  • CPU Architecture: x86_64

Information to attach

Affected files, all Ubuntu/Debian variants share the same _resolve_kernel_version() implementation:

  • ubuntu16.04/nvidia-driver
  • ubuntu18.04/nvidia-driver
  • ubuntu20.04/nvidia-driver
  • ubuntu22.04/nvidia-driver
  • ubuntu24.04/nvidia-driver
  • vgpu-manager/ubuntu20.04/nvidia-driver
  • vgpu-manager/ubuntu22.04/nvidia-driver
  • vgpu-manager/ubuntu24.04/nvidia-driver

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions