How do you build out-of-tree modules, e.g., nvidia modules for customized kernel?

Hey guys. I have a XanMod kernel compiled on Fedora 32.

I have been struggling finding a way to get the NVIDIA kernel modules working for both stock kernels and my customized ones.

With the official nvidia driver installer and dkms framework, my customized kernel has the out-of-tree modules working but not so good for the stock kernels. The dkms framework actually builds the modules for stock kernels, but it gives exec format error when I try to modprobe them.

With fedora nvidia* packages instead, the nvidia driver modules work well only for the stock kernels, and for my customized kernel I don’t even find a way to build them.

Do you guys have a good solution to share?

For stock kernels the instructions and modules are at https://rpmfusion.org/Howto/NVIDIA

I can’t help with the customized kernel, but you said that your dkms framework has those drivers working.

1 Like

I still can’t get the fedora nvidia driver rpms compiling kernel modules for my customized kernel. However I finally manage to have the stock kernel work with the official NVIDIA driver installer.

It’s well known that the kernel modules are stored in the /lib/modules/<your kernel name>/ and its subdirectories.

The key of switching from using rpms to official installer, is to remove the original .ko files installed by nvidia-kmod packages and its dependencies before dkms framework starts to compile new modules, or it will generate some modules in the weak-updates and the stock kernel still loads the old nvidia driver modules. After the new kernel modules are properly installed, make sure to regenerate the initramfs with dracut tool.

So, here comes the solution:

  1. Remove the old nvidia driver modules in the kernel modules folder, i.e., deleting nvidia.ko, nvidia_drm.ko, nvidia_uvm.ko and nvidia_modset.ko.
  2. Use dkms to install new modules, e.g., execute: sudo dkms install nvidia/455.23.05 -k 5.8.14-200.fc32.x86_64.
  3. Generate a new initramfs: sudo dracut /boot/initramfs-5.8.14-200.fc32.x86_64.img 5.8.14-200.fc32.x86_64 --force
  4. Other actions such as blacklisting the nouveau module to let nvidia function. Then reboot.
1 Like

I was able to use the XANMOD+NVIDIA from rpmfusion for some time, but i kind lost it and not sure how to make it work again.

When u have a normal kernel and u install the akmod-nvidia package, it finds ur kernel-source and builds a RPM package for it that is stored in /var/cache/akmods/nvidia/package with even a log of the build.

I was able to build that package (or the AKMOD system was…) but now its saying it dont know where my xanmod kernel source code is. I tried to soft-link the xanmod source i use but AKMOD dont accept it anymore. I think its something related to the packages i have installed in my system, but i’m kind lost in what to try.

If someone knows how to fix this, i would appreciate it.

I still can’t get the fedora nvidia driver rpms compiling kernel modules for my customized kernel. However I finally manage to have the stock kernel work with the official NVIDIA driver installer.

It’s well known that the kernel modules are stored in the /lib/modules/<your kernel name>/ and its subdirectories.

The key of switching from using rpms to official installer, is to remove the original .ko files installed by nvidia-kmod packages and its dependencies before dkms framework starts to compile new modules, or it will generate some modules in the weak-updates and the stock kernel still loads the old nvidia driver modules. After the new kernel modules are properly installed, make sure to regenerate the initramfs with dracut tool.

So, here comes the solution:

  1. Remove the old nvidia driver modules in the kernel modules folder, i.e., deleting nvidia.ko , nvidia_drm.ko , nvidia_uvm.ko and nvidia_modset.ko. You should issue something like sudo dkms remove nvidia/455.23.05 -k 5.8.14-200.fc32.x86_64 to make it. And when there are leftover of either module, you should then manually remove it with rm.
  2. Use dkms to install new modules, e.g., execute: sudo dkms install nvidia/455.23.05 -k 5.8.14-200.fc32.x86_64 .
  3. Generate a new initramfs: sudo dracut /boot/initramfs-5.8.14-200.fc32.x86_64.img 5.8.14-200.fc32.x86_64 --force
  4. Other actions such as blacklisting the nouveau module to let nvidia function. Then reboot.

Great that you point out the possibility of making the packaged NVIDIA driver from rpmfusion with XANMOD.

Hopefully someone can give us some good advice.