Tuesday, September 6, 2011

Installing Nvidia Driver From Nvidia.com

There are several ways to install the driver for your Nvidia card in Debian.
To find out which videocard you have :
lspci | grep VGA 
In my case : 01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce GT 330] (rev a2)
So my card is a GeForce GT 330.
To get the latest driver just go to this page ( choose Option 1 ) : http://www.nvidia.com/Download/index.aspx?lang=en-us. The latest driver at this moment is Version 280.13 Certified Release Date: 2011.08.01.
Just press the Download and Agree & Download button and the file NVIDIA-Linux-x86_64-280.13.run will be saved ( I use 64 bit ). The NVIDIA graphics driver uses a Unified Driver Architecture: the single graphics driver supports all modern NVIDIA GPUs.
A complete list for all the Unix Drivers is on this page : http://www.nvidia.com/object/unix.html
The NVIDIA graphics driver is bundled in a self-extracting package. You can extract it with :  
sh NVIDIA-Linux-x86_64-280.13.run --extract-only  
Verifying archive integrity... OK Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 280.13..............................................................................................................................................

A folder NVIDIA-Linux-x86_64-280.13 is created containing the uncompressed contents of the .run file. On Linux-x86_64, that file contains both the 64-bit driver binaries as well as 32-bit compatibility driver binaries.
Documentation can be found in :  
NVIDIA-Linux-x86_64-280.13/html/index.html and  
NVIDIA-Linux-x86_64-280.13/README.txt

To be able to install the driver we need first :  

apt-get install build-essential linux-headers-$(uname -r )

Before attempting to install the NVIDIA driver you should first disable Nouveau. Nouveau ( http://nouveau.freedesktop.org/wiki/ ) is a display driver for Nvidia GPUs, developed as an open-source project through reverse-engineering of the Nvidia driver. Nouveau performs modesets in the kernel. This can make disabling Nouveau difficult, as the kernel modeset is used to display a framebuffer console, which means that Nouveau will be in use even if X is not running. As long as Nouveau is in use, its kernel module ( nouveau.ko ) cannot be unloaded, which will prevent the Nvidia kernel module from loading. It is therefore important to make sure that Nouveau's kernel modesetting is disabled before installing the Nvidia driver. ( see the README.txt ).

To avoid problems later I start with :
apt-get purge xserver-xorg-video-nouveau
and reboot.
After rebooting do not login and switch to the first virtual (not graphic) terminal by :
Ctrl+Alt+F1
login as root, just enter : root and enter root's password.
Stop the X server by : /etc/init.d/gdm3 stop
Navigate to where you downloaded the driver :  
cd /home/$USER/Downloads 
sh NV*.run
The .run file is a self-extracting archive. When executed, it extracts the
contents of the archive and runs the contained nvidia-installer utility,
which provides an interactive interface to walk you through the installation.

nvidia-installer will also install itself to /usr/bin/nvidia-installer,
which may be used at some later time to uninstall drivers, auto-download
updated drivers, etc.
 

Just hit Tab and Enter to accept the license....


Say Yes to :
Install NVIDIA's 32 - bit compatibility OpenGL libraries ?  if you run amd64.
Say Yes to :
Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the NVIDIA X driver will be used when you restart X ? Any pre-existing X configuration file will be backed up.

A logfile can be found here : /var/log/nvidia-installer.log

The nvidia-installer will also write a file nvidia-installer-disable-nouveau.conf ( /etc/modprobe.d/nvidia-installer-disable-nouveau.conf ) containing these lines :
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0


Start the X server again :
/etc/init.d/gdm3 start
Login and check that the nvidia driver is running :
glxinfo | grep rendering
direct rendering: Yes

You can access nvidia-settings in the menu : System > Preferences > NVIDIA X Server Settings that allows adjustment of several additional settings.


For the settings to be loaded on login add :
nvidia-settings --load-config-only
to Startup Applications : System > Preferences > Startup Applications
If this doesn't work make sure you have unchecked Include X Display Names in the Config File in NVIDIA X Server Settings at nvidia-settings Configuration.

Notes :

(1) At the installation you can get a warning like :
No precompiled kernel interface was found to match your kernel; would you like the installer to attempt to download a kernel interface for your kernel from the NVIDIA ftp site (ftp://download.nvidia.com)?
Just answer No and continue.....
or
the installer complains that the gcc version is different from what was used to compile the kernel...
If you know what you are doing and want to ignore the gcc version check, select "No" to continue installation. Otherwise, select "Yes" to abort installation, set the CC environment variable to the name of the compiler used to compile your kernel, and restart installation.
Answer No, but if it fails you can temporarily set the gcc version (to 4.3 for example) by:

export CC=gcc-4.3
before running the Nvidia installer file.

(2) Any kernel update or xserver-xorg-core update will force you to reinstall the driver.
Just use one of the advanced options of the nvidia-installer ( /usr/bin/nvidia-installer ) :
Ctrl+Alt+F1
login as root, just enter : root and enter root's password.
/etc/init.d/gdm3 stop
nvidia-installer --update

If there is a more recent driver available, it will be automatically downloaded and installed.
See also : http://forums.debian.net/viewtopic.php?f=16&t=56833
To see the advanced options of the nvidia-installer just run in a terminal :
nvidia-installer -A

You can always check the current install status to see if it needs to be re-installed:
as root run :
nvidia-installer --sanity

Press OK :

To install the driver for another kernel without uninstalling the driver for the current kernel just boot into the other kernel and install the driver with :
nvidia-installer -K ( K = --kernel-module-only ) :
Install a kernel module only, and do not uninstall the existing driver. This is intended to be used to install kernel modules for additional kernels (in cases where you might boot between several different kernels). To use this option, you must already have a driver installed, and the version of the installed driver must match the version of this kernel module.

5 comments:

  1. thank you for nvidia driver install guide.

    ReplyDelete
  2. Thanks a lot!! This is the first Nvidia driver install guide for Debian that helps me to complete the installation without errors and Xorg failures.

    ReplyDelete
  3. beautiful guide, thank you

    ReplyDelete
  4. Thank you for sharing :)

    ReplyDelete
  5. Thanks for your how-to. I managed to get nvidia 295.53 running with kernel 3.2.0-2-amd64 (Debian unstable).

    ReplyDelete

Note: Only a member of this blog may post a comment.