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
- Run a kernel with a non-standard version string (e.g. a custom-built kernel using git-describe naming)
- Ensure the corresponding
linux-headers-$(uname -r) package is available in the apt repository
- 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
Describe the bug
_resolve_kernel_version()in the Ubuntu nvidia-driver scripts assumes kernel versions follow Ubuntu'smajor.minor.patch-revision-flavornaming 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 matchinglinux-headers-*package exists.The function extracts a version via regex from the
Version:field and a flavor viased 's/[^a-z]*//'fromuname -r, then concatenates them. For non-standard kernels this produces a mangled, non-existent version. For example:uname -r:6.5.13custom-00004-g00fabdb6286a6.5.13-00004custom-00004-g00fabdb6286a6.5.13-00004-custom-00004-g00fabdb6286a(does not exist)6.5.13custom-00004-g00fabdb6286a(matchesuname -rexactly)To Reproduce
linux-headers-$(uname -r)package is available in the apt repositoryExpected behavior
When
linux-headers-${KERNEL_VERSION}already exists as a valid package for the exactuname -routput, the driver should use it as-is without attempting to decompose and reconstruct the version string.Environment (please provide the following information):
gpu-driver-containersource: HEAD ofmain6.5.13custom-00004-g00fabdb6286a)x86_64Information to attach
Affected files, all Ubuntu/Debian variants share the same
_resolve_kernel_version()implementation:ubuntu16.04/nvidia-driverubuntu18.04/nvidia-driverubuntu20.04/nvidia-driverubuntu22.04/nvidia-driverubuntu24.04/nvidia-drivervgpu-manager/ubuntu20.04/nvidia-drivervgpu-manager/ubuntu22.04/nvidia-drivervgpu-manager/ubuntu24.04/nvidia-driver