How do I update my nvidia modules after updating my kernel?

43,735

Solution 1

If you have installed the NVIDIA driver as an ubuntu package, it should be updated automatically after each kernel upgrade.

You can install the packaged driver using the Additional Drivers tool in the dashboard, or installing the package nvidia-current.

If you have installed the nvidia driver directly from their website it is probably sensible to remove it before installing this package - I'm not certain how good it will be at detecting the conflict.

If you have installed the package from the ubuntu repositories, you can try reconfiguring it with dpkg-reconfigure but I suspect building the nvidia module is triggered by installing a new kernel, and I'm not sure how to trigger this otherwise. The traditional uninstall and re-install might well work (sudo apt-get remove nvidia-current; sudo apt-get install nvidia-current).

Solution 2

For me dpkg-reconfigure rebuilds the Nvidia driver with the latest kernel. This then requires a reboot to take effect. My example below uses the older nvidia-304-updates.

sudo dpkg-reconfigure nvidia-304-updates

EDIT: I managed to automate this by writing a script zz-dkpg-reconfigure-nvidia that runs after kernel updates

#!/bin/bash
#
# Reconfigure nvidia driver

DRIVER=nvidia-304-updates

dpkg-reconfigure $DRIVER > /var/log/dpkg-reconfigure-nvidia.log 2>&1

exit 0

I installed the above script by running

sudo install zz-dkpg-reconfigure-nvidia /etc/kernel/postinst.d

Works on my Ubuntu 14.04 kernel 3.13.0-29 to 3.13.0-36 update.

Solution 3

When you have installed the NVIDIA binary driver, you probably haven't installed the dkms package. Dkms makes sure that every time you update kernel, modules which support it are recompiled:

sudo apt-get install dkms

You would probably need to re-install the NVIDIA binary drivers afterwards, and allow to use DKMS during the setup as it needs to be registered with it.

Solution 4

If you want to rebuild the kernel modules only, then you might just want to execute

sudo apt-get install --reinstall nvidia-current

if you have nvidia-current installed, or if you have nvidia-331 installed then this should do the work:

sudo apt-get install --reinstall nvidia-331

no need to add a repo or install new software :-)

Solution 5

Please note that neither installing a kernel upgrade nor drivers from officially unsupported repositories is recommended! Follow these instructions at your own risk and only if you know what you're doing!

If you installed an kernel that's ahead of current official Ubuntu repositories (e.g. kernel 3.4 or 3.5) you might not succeed with simply reinstalling nvidia drivers.

The only way I found so far to get nvidia-drivers to work again is by adding the following ppa to your repositories. In a terminal type:

sudo add-apt-repository ppa:xorg-edgers/ppa

After that, do a sudo apt-get update and sudo apt-get install nvidia-current.

That should do the trick. If not, run an additional sudo apt-get upgrade.

Share:
43,735

Related videos on Youtube

fazineroso
Author by

fazineroso

Updated on September 18, 2022

Comments

  • fazineroso
    fazineroso almost 2 years

    Every time there's a kernel update, nvidia graphics drivers stops working because there's not a valid kernel module.

    What is the ubuntu way to 'recompile' the nvidia module for the new kernel?

    Shouldn't it be done automatically? I am suffering a bug?

  • fazineroso
    fazineroso almost 12 years
    I installed the nvidia driver through an Ubuntu package. But updating the kernel didnt trigger the recompilation of my nvidia module. Thanks for your tips anyway.
  • yaobin
    yaobin almost 6 years
    I am encountering the same issue and just realized I haven't installed dkms after reading this answer.
  • rustyx
    rustyx over 2 years
    I have dkms installed and yet I had to do sudo dpkg-reconfigure nvidia-kernel-dkms