Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: HOWTO: Install Nvidia drviers including DKMS module

  1. #1
    Join Date
    Aug 2006
    Beans
    278

    HOWTO: Install Nvidia drivers including DKMS module

    I figured out the last days how to correctly setup DKMS for newer Versions of the NVidia-Driver. In case you dont know, DKMS is a nifty little system that will ensure you dont run into trouble if you install a new kernel. Running a new Kernel requires ALL modules to be recompiled, and in the case of propietary drivers (ie drivers you dint install through apt-get) this task is left to you.
    DKMS is there to automate this very task, you wont ever have to care for kernel-upgrades again.

    I wrote a little script(attached) that extracts the necessary parts from the NVIDIA-Driver and can configure DKMS.

    Who can use this tutorial
    Theoretically the procedure should work on all Ubuntus that have the necessary packages (Gutsy and later), I only tested this on Intrepid tough. It should work with all current and future NVIDIA-Installers (180, 173, 96 and 71 Series ).
    • Your OS should be Ubuntu - Gutsy or later. Earlier versions should work too if you manage to manually install DKMS but I wont cover that
    • You need a Nvidia Card obviously, and the official NVIDIA-Installer Latest Versions can be found here


    Heres the instructions how to use the latest NVIDIA-Driver on Ubuntu and configure DKMS for it:

    Step 1: Uninstall the Nvidia-driver from the repositories (if you installed it from there)
    Use the Restricted Driver Manager and/or do it by commandline.
    This depends on your Version of Ubuntu and the Driver you previously installed (via apt-get or Restricted driver manager). Search for packages containing nvidia in the name in synaptic, generally you should unistall all nvidia*glx* and nvidia*kernel* packages. for example:
    Code:
    sudo apt-get remove nvidia-glx-180 nvidia-180-kernel-source nvidia-xconfig nvidia-settings
    Step 2: Keep Ubuntu from using the driver in the repos
    Open the file /etc/default/linux-restricted-modules-common

    Code:
    sudo gedit /etc/default/linux-restricted-modules-common
    and add the modules nv nvidia_new to the list of disabled modules.
    Code:
    DISABLED_MODULES="nv nvidia_new"
    This will keep the restricted driver Manager from nagging.

    Step 3: Prepare the Files and packages you will need
    Packages necessary to build the kernel module:
    Code:
    sudo apt-get install dkms build-essential make
    You will also need the Kernel-header for ALL the kernels you plan to use (typically linux-headers-generic or linux-headers-rt), you need to make sure you pick the right one(s). To install the headers for Ubuntu`s normal Kernel:
    Code:
    sudo apt-get install linux-headers-generic
    Get the NVIDIA Binary driver for your system (32 or 64 Bit). Follow the links from here

    Grab my script (attached) for configuring DKMS and unpack it in the same directory as the NVIDIA-Driver.

    running the script as non-root will only do some sanity-checks so I suggest you so so now by typing (replace 180.37 with the version you are installing)
    Code:
    sh ./installdkms.sh 180.37

    Step 4: Installing the driver
    Reboot ubuntu into safe mode and choose root-prompt, this is IMHO the easiest way to drop into an environment where you can safely install the driver. You might not have internet-connectivity tough, thats why you installed all the packages before.

    Now cd into the directory where you saved the NVIDIA-Driver and the script. For example:
    Code:
    cd /home/<yourusername>
    First part is to install the Driver, the command ofcourse depends on the filename, example:
    Code:
    sh ./NVIDIA-Linux-x86_64-180.37-pkg0.run
    Follow the instructions, they are pretty obvious I guess. If it complains about beeing in runlevel 1 just tell it to continue anyway.
    If you are on Hardy or later I suggest you dont let the Installer configure your xorg.conf but do so yourself. The Installer will produce a working configuration, but its better to do so by Hand, read up Appenix A before rebooting.

    now run the script, you need to replace 180.37 with the driverversion you are going to install
    Code:
    sh ./installdkms.sh 180.37
    If everything turns out ok, you can query the state of DKMS. Heres the output on my system:
    Code:
    dkms status
    nvidia, 180.37, 2.6.27-11-generic, x86_64: installed
    last Step is to exit the commandline and boot into ubuntu normally
    Code:
    shutdown -r 0
    Appendix A: Telling X to use the nvidia driver
    If you told the installer to adjust the xorg.conf file you dont need to do anything.
    And if you have trouble with this step you can still do it automatically by running "nvidia-xconfig"

    If you choose to edit it manually (highly recommended) then execute
    Code:
    vim /etc/X11/xorg.conf
    Hardy and later have a pretty minimalistic or even nonexistant xorg.conf, this is the whole file for my system:
    Code:
    Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
    EndSection
    Appendix B: Script for running the nvidia-installer
    I also added a script which installs the base driver, creates a xorg.conf only if noone exists and then runs the installDKMS.sh script. This should work well if you already have xorg.conf edited or are running a fresh Ubuntu (Hardy or newer) which has no xorg.conf.
    Simply follow the steps in this tutorial untill you have to run the NVIDIA-Installer and instead run (replace 180.37 with your version)
    Code:
    sh ./fullinstallNV.sh 180.37
    Then reboot

    Appendix C: Removing old DKMS Modules
    If you installed previous drivers you will have multiple Nvidia Modules. You can delete the old DKMS Modules with
    Code:
    sudo dkms remove -m nvidia -v <oldversion> --all
    Unfortunatly that still leaves the source behind, so delete that aswell:
    Code:
    sudo rm -rf /usr/src/nvidia-<oldversion>

    Update 23.1.2008: Added fixes from jdillaczek and jocko - Script is at V2
    Update 26.1.2008: Now also works if NVIDIA-Installer is not marked executable, added lotsa comments - Script is at V3
    Update 10.3.2008: Now needs driverversion as argument, tested and worked with all current (legacy) NVIDIA Installers - Script is at V4
    Attached Files Attached Files
    Last edited by Npl; March 10th, 2009 at 03:36 PM.

  2. #2
    Join Date
    Jan 2006
    Location
    Vancouver, Canada
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Nifty!
    Just trying this out now, but thanks in advance

  3. #3
    Join Date
    Aug 2006
    Beans
    278

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Hmm, hope everything goes well for you. The script got DL 19 times with one response, so if I dont hear back from you I will assume I`m responsible for 19 blownup Computers.

  4. #4
    Join Date
    Aug 2008
    Beans
    2

    Re: HOWTO: Install Nvidia drviers including DKMS module

    That is a nifty little script -- thanks for figuring this out and sharing the solution! Here are a few typos I noticed (and I had to remove the -q option from the dkms commands; otherwise the script would just exit at that point -- not sure what's up with that): change line 48 from

    Code:
    if [ sanity != 1 ]
    to

    Code:
    if [ $sanity != 1 ]
    and line 71 from

    Code:
    $installername --extract-only --target $tempdir/installer
    to

    Code:
    ./$installername --extract-only --target $tempdir/installer
    and line 80 from

    Code:
    cp $tempdir/installer/$installersourcedir/* $destsourcedir
    to

    Code:
    cp -r $tempdir/installer/$installersourcedir/* $destsourcedir
    (and remove the -q option from dkms commands on lines 95, 100, 103, and 106).

  5. #5
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,181
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Install Nvidia drviers including DKMS module

    One more typo at row 16:
    Change from:
    Code:
    packagedepencies=(dkms build-essentials make)
    To:
    Code:
    packagedepencies=(dkms build-essential make)
    But there seems to be one more problem. When I run the script it ends with:
    Code:
    Moving kmodule-source to /usr/src/nvidia-180.22
    Creating dkms-configuration /usr/src/nvidia-180.22/dkms.conf
    Delete temporary directory
    Removing all previous DKMS Modules
    
    Error! There are no instances of module: nvidia
    180.22 located in the DKMS tree.
    Edit: I managed to get it to complete successfully by commenting out line 95, so that it does not try to remove something that is not there (is it likely that anyone would need to run the script again if the module is already in the dkms tree?).
    I don't know much about bash, but wouldn't it be possible to make the script first check if there are any nvidia modules in the dkms tree, and only try to remove them if they really are there?

    Edit 2: I tried again. First I removed the module with:
    Code:
    dkms remove -m nvidia -v 180.22 --all
    Then I reverted line 95 to it's original form:
    Code:
    dkms remove -m nvidia -v $driverversion --all -q
    And it worked without errors. So the -q needs to be there on line 95, otherwise the script will stop with an error if the module does not already exist...

    Edit 3: I added a line (72) to the script to get it to run the actual installer as well.
    So I attach a modified version of the script (with both jdillaczek's and my fixes).

    The instructions for using the script to both install using nvidia's installer and add the module to dkms:
    1. Unpack the tar.gz containing the script to the same folder as the nvidia installer (~/Desktop).
    2. Go to cli-only mode (by some reason required by nvidia's installer):
    Code:
    sudo /etc/init.d/gdm stop
    3. Navigate to where the installer and script is located:
    Code:
    cd ~/Desktop
    4. Run the script:
    Code:
    sudo ./installdkms.sh
    5. Restart gnome:
    Code:
    sudo gdm
    Attached Files Attached Files
    Last edited by jocko; January 23rd, 2009 at 07:41 AM.

  6. #6
    Join Date
    Aug 2006
    Beans
    278

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Thanks for the feedback, I added jdillaczek fixes and made sure the script is not stopping at errors from the dkms-commands - they have undocumented returnvalues and generally are behaving a bit weird. Now theres a bit more verbose output since i removed the -q options aswell.

    jocko: You need to drop out of the GUI since you cant replace kernelmodules while you are using them. Also I dont want to call the NVIDIA-Installer from within the script, its complex enough to warrant its explicit call.

  7. #7
    Join Date
    Jan 2007
    Location
    $here ? $here : $there
    Beans
    3,717
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Nice tutorial. Moved to tutorials and tips. You may also want to point out that this is for Intrepid and above. The same can be accomplished on Hardy (or any version actually) with: HOWTO: Automatically update manually installed NVidia drivers after kernel updates
    Don't try to make something "fast" until you are able to quantify "slow".

  8. #8
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,181
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Quote Originally Posted by Npl View Post
    jocko: You need to drop out of the GUI since you cant replace kernelmodules while you are using them. Also I dont want to call the NVIDIA-Installer from within the script, its complex enough to warrant its explicit call.
    I knew why nvidia wants the installer to run from a pure cli, I just think it would be equally good if the installer just built the module and let the user restart xorg afterwards to load the new module.

    And I noticed one thing in your howto that may cause problems:
    Nvidia's installer does not run from runlevel 1 (single user mode/recovery mode).
    At least in my case it just complains about the runlevel and exits, so I have to boot normally (runlevel 2) and exit the gui by stopping gdm (sudo /etc/init.d/gdm stop), then run the installer with sudo.
    Or have nvidia changed this behaviour of the installer lately (I know that at least the first beta version of the 180.xx series driver still did this)?

    Other than that, I just tested your new script with a clean dkms tree and now it works fine and continues even if the "dkms remove" command can't find a module to remove.
    Thank you for an excellent howto.
    Last edited by jocko; January 23rd, 2009 at 07:06 PM.

  9. #9
    Join Date
    Aug 2006
    Beans
    278

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Quote Originally Posted by jocko View Post
    And I noticed one thing in your howto that may cause problems:
    Nvidia's installer does not run from runlevel 1 (single user mode/recovery mode).
    It will warn about the runlevel but continue if you say so. Since Ubuntu uses runlevels quite differently it doesnt matter. In my case I dont have network-access tough.

    Anyway I found installing the driver in fail-safe mode through Grub(runlevel 1) alot easier than stopping all relevant services. Sometimes the kernelmodule dint get replaced when I just stopped gdm.

    sdennie: I know this will work for Intrepid and Nvidia 180.xx, but I think it should work with Hardy and eventually previous Ubuntus that have the necessary packages. Should also work the same with other Nvidia-Drivers...
    Last edited by Npl; January 23rd, 2009 at 07:27 PM.

  10. #10
    Join Date
    Nov 2005
    Location
    Uppsala, Sweden
    Beans
    2,181
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: HOWTO: Install Nvidia drviers including DKMS module

    Quote Originally Posted by Npl View Post
    It will warn about the runlevel but continue if you say so. Since Ubuntu uses runlevels quite differently it doesnt matter. In my case I dont have network-access tough.

    Anyway I found installing the driver in fail-safe mode through Grub(runlevel 1) alot easier than stopping all relevant services. Sometimes the kernelmodule dint get replaced when I just stopped gdm.
    Nevermind. I was wrong on the runlevel thing, it was apparently just a warning and the installer actually continues if I say "no"... I just didn't read it properly last time... so leave that part as it is now, it's easier and more reliant than just stopping gdm.

    But I realized one more tip: When you are in runlevel 1 after booting to recovery mode, you don't have to reboot to reach the gui, just run "init 2". That will be faster than a complete reboot but will have the exact same result.
    Last edited by jocko; January 23rd, 2009 at 07:39 PM.

Page 1 of 5 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •