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.

I’m now using XANMOD+NVIDIA from rpmfusion.

The NVIDIA driver from RPMFUSION works out of the box when i install akmod-nvidia e kmod-nvidia. It builds normally from every of the official kernels from repos, even “update-testing”.

To ask AKMOD system to build a RPM package with NVIDIA driver with a custom kernel, it this case, xanmod’s:

  1. Have nvidia already installed ( install akmod-nvidia and kmod-nvidia and reboot to test )
  2. Build and install your custom kernel ( make, sudo make modules_install install )
  3. Check the logs from /var/cache/akmods/nvidia and see that the build fails. Try to reverse it i manage to rebuild with my custom kernel. Was inside the folder(kernel source), not sure this is needed.

"akmodsbuild --kernel 5.9.8-xanmod1 /usr/src/akmods/nvidia-kmod.latest "

  1. Install the RPM that the akmodsbuild : sudo dnf localinstall name-of-the-nvidia-xanmod.rpm ; mine was kmod-nvidia-5.9.8-xanmod1-455.38-1.fc33.x86_64.rpm

  2. Reboot

Extra-info: i have lots of development packages and package groups like @development-tools and @rpm-developlment-tools installed. Not sure this impacts or not in the build success, but i have a slight tendency to think that is does help.

Extra:

  1. Remember you have to do some config based on the use of your NVIDIA card. I have a notebook with dual GPU, and i used KDE. I also have an extra monitor ( yes, its 2020 and we still need to customize this kind of stuff ). This was not part of the original post, so i will just let the link to references. Give me a shout if someone needs any help.

Good job! You really find guys like me a good solution.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.