Solved Nvidia driver with multiple kernels

Solved issue

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
4,004
Reaction score
4,252
Credits
32,768
I have 2 kernels installed:

Bash:
dpkg --list | grep linux-image

ii  linux-image-6.7.12+bpo-amd64                             6.7.12-1~bpo12+1                       amd64        Linux 6.7 for 64-bit PCs (signed)
ii  linux-image-6.9.7+bpo-amd64                              6.9.7-1~bpo12+1                        amd64        Linux 6.9 for 64-bit PCs (signed)
ii  linux-image-amd64                                        6.9.7-1~bpo12+1                        amd64        Linux for 64-bit PCs (meta-package)

I'm using only the 6.9.7 one (booted by default) which is recent and the other one is supposed to be used only if recent one fails, or for testing purposes or what ever.

However since I'm installing Nvidia driver from nvidia.com rather than from Debian repo this means when ever Nvidia driver is installed or updated the changes will be applicable only to the recent kernel and the older kernel will not be usable for graphical session.

I think this is so because during driver installation I'm asked whether to rebuild initramfs, I choose "Yes" and this makes the recent kernel boot with the installed driver.
Now I don't fully understand the role of initramfs except that it's updated for the new driver for the recent kernel (or currently booted one? IDK)

What I would like to achieve is to make both kernels usable with Nvidia driver so that which ever I choose in both cases the latest Nvidia driver is loaded and so both kernels are usable for graphical session.
But how to do that? how to update initramfs so that both kernels boot with the driver?

Currently if I attempt to boot older kernel the boot process will stuck because Nvidia driver is not "registered" for that kernel.
Also if new kernel is installed then also Nvidia driver needs to be reinstalled otherwise the only option is to reinstall system because no kernel is configured to boot with the new driver.

Btw. I don't want DKMS, I'd prefer to do this manually if possible, I only want Nvidia driver to be installed so that both kernels are usable with it.

EDIT:
After a bit of research, it seems that during driver installation kernel headers are used to compile the driver, used headers are those for currently loaded kernel and so the driver is built for that kernel.

So if I want it built the driver for both kernels I'd need to boot into each one separately and build the driver twice (for each), however I'm not sure if that will create 2 copies of the driver for each kernel?
I suspect only one driver will be installed, for which ever kernel was loaded last right? because installation procedure uninstalls previous driver.

Also simply updating initramfs for older kernel is unlikely to work because the driver is built for one kernel only.
 
Last edited:


I can't help with Debian or in fact any distro "customization" but it is/was pretty easy with nvidia driver downloaded directly from manufacturer's site.
Install nvidia for the kernel that you run. Next install nvidia for the offline kernel.
Code:
sh NVIDIA-Linux-x86-x.x.x.run -K -k kernel-name -a

Catch, you need to uninstall drivers for the offline kernel before updating.
Note, I was doing this until 2017 (when I had to change laptop and got all Intel) so doublecheck the syntax.

Hopefully will work for you
 
Catch, you need to uninstall drivers for the offline kernel before updating.
Any idea of a location where the is driver installed?
I'd like to make sure 2 drivers for different kernels can be both installed, but in any case I'll test this scenario, already preparing to reinstall system in case if things go wrong.
 
Install nvidia for the kernel that you run. Next install nvidia for the offline kernel.
Code:
sh NVIDIA-Linux-x86-x.x.x.run -K -k kernel-name -a
Catch, you need to uninstall drivers for the offline kernel before updating.
Thank you very much! this works like charm :)

With your help I figured out the -A option will list a ton of installer options, in addition to -K and -k it also mentions option -a is deprecated, so in my case it was sudo ./NVIDIA-Linux-x86_64-x.x.x.run -K -k 6.7.12+bpo-amd64

It's also important to rebuild initramfs when asked by the installer.

Any idea of a location where the is driver installed?
Figured out from here:

The location /lib/modules/$(uname-r)/kernel/drivers/video/ now lists drivers for both kernels.

Thanks @Aristarchus
 
With your help I figured out the -A option will list a ton of installer options, in addition to -K and -k it also mentions option -a is deprecated, so in my case it was sudo ./NVIDIA-Linux-x86_64-x.x.x.run -K -k 6.7.12+bpo-amd64
You should use dkms if you are going to install that driver manually.
 
I really like the project and was already thinking about that if nothing else then to learn more about Linux.

However problem is there won't be package manager and people to maintain packages, something which I don't like to do so I'd need to manually update software and manually check for updates in various code repositories which is time consuming and would need to be done every day afterwards.
 
However problem is there won't be package manager and people to maintain packages, something which I don't like to do so I'd need to manually update software and manually check for updates in various code repositories which is time consuming and would need to be done every day afterwards.
More control with no package manager :P
 
I actually needed an Nvidia driver for a CentOS Stream 10 where there are not package Nvidia drivers yet, I found out if you have dkms installed and then run the RUN file it will detect you have dkms installed and then setup the dkms part for you so that you won't have to do it manually yourself.
 
You should use dkms if you are going to install that driver manually.
Sorry but I'm control freak, I prefer to do everything manually and from scratch
btw. things have changed here and I've figured out using DKMS is much better than manual approach, so I've listened to you.

It is pretty simple to setup official Nvidia driver with DKMS:

Bash:
sudo apt install dkms
sudo systemctl set-default multiuser.target
systemctl reboot

Then reinstall driver and set graphical again.
During driver installation I was asked whether to register it with DKMS and that was it.

One important step that Registering the NVIDIA Kernel Module with DKMS does not say but is applicable to Debian is we need to make sure to install linux-headers-amd64 instead of linux-headers-$(uname -r) because the prior ensures that latest headers are installed every time kernel is upgraded so that DKMS can build the driver.

Without this, one needs to manually install the headers every time or DKMS would fail.
 
Last edited:
btw. things have changed here and I've figured out using DKMS is much better than manual approach, so I've listened to you.
Yeah you just install dkms, during installation of a new run file it will ask you if you want to register the new module with dkms. Then when you get kernel updates the new Nvidia kernel module will be built automatically without you having to reinstall the driver again.
 
No you just run the run file and it will build the new kernel module and then ask you if you want to register it with dkms if you have that installed.
OK, rn, sudo dkms status says:

nvidia/575.64.05, 6.12.43+deb13-amd64, x86_64: installed
So when I update the driver I'm supposed to see this entry removed and replaced with never driver?
e.g. there won't be 2 entries?

Still, I'm not sure DKMS would rebuild the driver of older/previous kernel?
 
Still, I'm not sure DKMS would rebuild the driver of older/previous kernel?
Yeah it does, just checked on the system I have where I install the driver like that.

Code:
[root@legion ~]# dkms status
nvidia/580.76.05, 6.12.0-122.el10.x86_64, x86_64: installed
nvidia/580.76.05, 6.12.0-125.el10.x86_64, x86_64: installed
nvidia/580.76.05, 6.12.0-126.el10.x86_64, x86_64: installed
So it builds the current driver for all the kernels you have installed.
 


Follow Linux.org

Members online


Top