NVIDIA Driver Installation nvidia: version magic '4.4.0-116-generic SMP mod_unload modversions ' should be '4.4.0-116-generic SMP mod_unload modversions retpoline '

I have a NVIDIA Quadro 600 and used to have an Nvidia driver v387.26 installed on my Ubuntu 16.04 machine until a few days ago when Ubuntu detected the drivers as useless packages and got them uninstalled when I did an autoremove command (huge mistake!). Now I am trying to reinstall the same version of driver, but constantly get this error:

ERROR: Unable to load the kernel module ‘nvidia.ko’. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if a driver such as rivafb, nvidiafb, or nouveau is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA graphics device(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

In an effort to pin point where the problem is coming from, I checked my version of gcc which is 5.4.0. Then, in my blacklist.conf file in /etc/modprob.d, I already have:

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0

The last segment of nvidia-installer.log is

[   17.508056] input: PS/2 Generic Mouse as /devices/platform/i8042/serio1/input/input4
[  260.918127] [drm] Initialized drm 1.1.0 20060810
[  260.953440] ipmi message handler version 39.2
[  260.962082] nvidia: version magic '4.4.0-116-generic SMP mod_unload modversions ' should be '4.4.0-116-generic SMP mod_unload modversions retpoline '
[  595.950385] [drm] Initialized drm 1.1.0 20060810
[  595.981152] ipmi message handler version 39.2
[  595.990135] nvidia: version magic '4.4.0-116-generic SMP mod_unload modversions ' should be '4.4.0-116-generic SMP mod_unload modversions retpoline '
ERROR: Installation has failed.  Please see the file '/var/log/nvidia-installer.log' for details.  You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.

Is this the problem where it says that “4.4.0-116-generic SMP mod_unload modversions” should be “4.4.0-116-generic SMP mod_unload modversions retpoline”? If so, does anyone have any idea how to solve this issue?

That’s a sideeffect from retpoline patches in gcc. Purge and reinstall the -116 kernel. See:
[url]https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/1750937[/url]

Hello,

i had the same problem with Ubuntu 14.04 LTS

It is related to the retpoline patches.
I think kernel has them and the new compiled module has not.
I don’t know why and if it is a compiler issue of if the Nvidia driver is responsible.

I manually edited the version magic here:
cd /usr/src/linux-headers-3.13.0-143
vim include/linux/vermagic.h

$diff -u include/linux/vermagic.h.ori include/linux/vermagic.h
— include/linux/vermagic.h.ori 2018-03-19 15:53:40.992262994 +0100
+++ include/linux/vermagic.h 2018-03-19 15:30:58.405250111 +0100
@@ -24,7 +24,8 @@
#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC “”
#endif
-#ifdef RETPOLINE
+/* #ifdef RETPOLINE */
+#if 1
#define MODULE_VERMAGIC_RETPOLINE "retpoline "
#else
#define MODULE_VERMAGIC_RETPOLINE “”

This enabled the magic word retpoline regardless if these patches are in there.
It is just a workaround until a real fix is there.

Desktop and driver now start again.

BR
Sven

This workaround restored my desktop/drivers as well. I would just add the command ‘sudo dpkg-reconfigure nvidia-387’ or ‘sudo dpkg-reconfigure nvidia-390’ as it is in my case. Then reboot and try to login again. Just trying to help people who might stumble into this solution from their searches.

As for my situation: I am on Ubuntu 14.04 x64 and was using the graphics-drivers PPA with nvidia-381 when everything was working fine. I tried to update to nvidia-384 from the same PPA with successful install according to apt (sudo apt install nvidia-384), however, on reboot, my display resolution was very low, and my second monitor had no output. I was booted to my login prompt at that very low resolution and after logging in, the GUI flashes black for a second and then returns back to the login prompt. I tried to install nvidia-390 hoping whatever bug nvidia-384 had would be fixed there, but both did the same thing.

Relevant snippet in /var/log/Xorg.0.log mentions this:

[    53.415] (EE) NVIDIA: Failed to initialize the NVIDIA kernel module. Please see the
[    53.415] (EE) NVIDIA:     system's kernel log for additional error messages and
[    53.415] (EE) NVIDIA:     consult the NVIDIA README for details.
[    53.415] (EE) [drm] KMS not enabled
[    53.415] (EE) open /dev/dri/card0: No such file or directory

Relevant snippet in /var/log/dmesg mentions this:

[   43.014595] nvidia: version magic '3.13.0-144-generic SMP mod_unload modversions ' should be '3.13.0-144-generic SMP mod_unload modversions retpoline '

Lucky for me, googling retpoline led me here first stop, and to Sven’s workaround.
I issued:

sudo cp /usr/src/linux-headers-3.13.0-144/include/linux/vermagic.h /usr/src/linux-headers-3.13.0-144/include/linux/vermagic.h.backup 
sudo nano /usr/src/linux-headers-3.13.0-144/include/linux/vermagic.h

changed the file from this:

#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif
#ifdef RETPOLINE
#define MODULE_VERMAGIC_RETPOLINE "retpoline "
#else
#define MODULE_VERMAGIC_RETPOLINE ""

to this, with the workaround:

#ifndef MODULE_ARCH_VERMAGIC
#define MODULE_ARCH_VERMAGIC ""
#endif
/* #ifdef RETPOLINE */
#if 1
#define MODULE_VERMAGIC_RETPOLINE "retpoline "
#else
#define MODULE_VERMAGIC_RETPOLINE ""

then issue:

sudo dpkg-reconfigure nvidia-390

change 390 to whatever version you are trying to install
and then issue a reboot and try to log back in

My advice would be to go to /var/cache/apt/archives/ and backup any nvidia-* deb files just in case you run into the situation I did. I was just fine on nvidia-381, before upgrading. But the PPA I used no longer published nvidia-381 at the time of my upgrade to nvidia-384 and nvidia-390. When both failed to install, I had no fallback to go to and couldnt reinstall nvidia-381 again because it didn’t exist on my system anymore. Usually these debs exist in /var/cache/apt/archives/ but do get cleaned out occasionally from the looks of it.

I thought the elaboration here helps others who may find this page

Hello azizLIGHT,

Nice to hear that my post helped you.

I thought the elaboration here helps others who may find this page
That was also my intention to post.

BR
Sven

@azazizLIGHT Thanks for your propose, I have solved by this.

I used an old Ubuntu kernel to avoid this bug up until yesterday that I had to eventually update to a new kernel. Used your workaround and it worked just fine.
Thank you for sharing.