2008-03-01

Debian - NVIDIA drivers

A quick and easy tutorial about how to install NVIDIA drivers as simply as possible.

Prerequisites:

As a starting point, download the latest stable drivers.

Then you’ll need to install a few packages :

$ sudo apt-get install build-essential linux-headers-$(uname -r)
Debian Sarge users have to replace linux-headers with kernel-headers.


Installation:

First you’ll need to kill the X server. You can do that by switching to console #1 : press CTRL-ALT-F1 simultaneously.

Once there, log in with your username and password.

Stop the graphical login manager :

$ sudo /etc/init.d/gdm stop
Then install the drivers :

$ sudo sh NVIDIA-Linux-x86-1.0-9755-pkg1.run
and follow the installation process.

Make sure you tell the installer to automatically modify your /etc/X11/xorg.conf file so you’ll end up using the NVIDIA drivers.


Xorg.conf:

If you haven’t, then you simply have to make a few changes to your /etc/X11/xorg.conf file. Here they are. Debian Sarge users have to modify /etc/X11/XF86Config-4 instead.

In Section “Modules” comment the dri and GLcore modules :

#Load "dri"
#Load "GLcore"

In Section “Device” make sure you use the NVIDIA driver :

Driver "nvidia"

And finally comment the whole Section “DRI” :

#Section "DRI"
# Mode 0666
#EndSection

Here is an example xorg.conf file with the proper changes made.


X:

Once done, load the NVIDIA module :

$ sudo modprobe nvidia
And restart the graphical login manager, which will bring back X :

$ sudo /etc/init.d/gdm start

Tips:

If you happen to update your kernel, then you don’t need to reinstall the whole NVIDIA driver, but only the kernel module. So running this command will do the trick :

$ sudo sh NVIDIA-Linux-x86-1.0-9755-pkg1.run -K

10 comments:

Anonymous said...

Installing NVIDIA drivers under Debian like this may not the most correct nor the simplest way.

Read about the proper way at http://wiki.debian.org/NvidiaGraphicsDrivers

You probably only need to run the following commands, answer "Y" a couple of times, and that's it:

aptitude install module-assistant
m-a a-i nvidia
aptitude install nvidia-glx

And later, after updating the kernel or when newer drivers are available at the Debian repository, you'll just have to run "m-a a-i nvidia".

Mika said...

No. That's not the simplest nor the preferred way to install Nvidia drivers on Debian. And no you don't need to use module-assistant either.

Here is how you can install Nvidia drivers.

First you need to activate Debian's non-free and contrib repositories. Make sure that there is something like this in the /etc/apt/sources.list

deb http://ftp.fi.debian.org/debian/ etch main non-free contrib
deb-src http://ftp.fi.debian.org/debian/ etch main non-free contrib
deb http://security.debian.org/ etch/updates main non-free contrib
deb-src http://security.debian.org/ etch/updates main non-free contrib

What matters are those 'non-free' and 'contrib' keywords at the end of lines. If you are using Debian Lenny replace etch with lenny. If you are using Debian unstable, replace etch with unstavle.

Next you need to update the package database:
# apt-get update

Next you need to check what kernel and cpu-type you have:
# uname -r

The result is something like this:
2.6.18-6-k7

What matters is the last part of the line, that's your cpu time. In this example cpu-type.

Now you can install the driver. Relace k7 with cpu-type which uname -r reported:
# apt-get install nvidia-kernel-2.6-k7
# apt-get install nvidia-glx
# apt-get install nvidia-settings

Mika said...

No. That's not the simplest nor the preferred way to install Nvidia drivers on Debian. And no you don't need to use module-assistant either.

Here is how you can install Nvidia drivers.

First you need to activate Debian's non-free and contrib repositories. Make sure that there is something like this in the /etc/apt/sources.list

deb http://ftp.fi.debian.org/debian/ etch main non-free contrib
deb-src http://ftp.fi.debian.org/debian/ etch main non-free contrib
deb http://security.debian.org/ etch/updates main non-free contrib
deb-src http://security.debian.org/ etch/updates main non-free contrib

What matters are those 'non-free' and 'contrib' keywords at the end of lines. If you are using Debian Lenny replace etch with lenny. If you are using Debian unstable, replace etch with unstavle.

Next you need to update the package database:
# apt-get update

Next you need to check what kernel and cpu-type you have:
# uname -r

The result is something like this:
2.6.18-6-k7

What matters is the last part of the line, that's your cpu time. In this example cpu-type.

Now you can install the driver. Relace k7 with cpu-type which uname -r reported:
# apt-get install nvidia-kernel-2.6-k7
# apt-get install nvidia-glx
# apt-get install nvidia-settings

Mika said...

Small typo fix:

"What matters is the last part of the line, that's your cpu time. In this example cpu-type."


What matters is the last part of the line, that's your cpu type. In this example cpu-type is k7.

uterrorista said...

Thanks "Anonymous" and Mika for you opinions.
We're always learning...

brunomiguel said...

Parabéns pelo destaque no Debian-news.net (http://debian-news.net/modules/news/article.php?storyid=4151)

Debian FTW!! xD

uterrorista said...

Já me tinha apercebido que as visitas tinham subido... mas porquê é que não.
Obrigado pelo aviso ;)

Anonymous said...

I tried to install the accelerated Nvidia drivers on a system with Debian lenny according to
http://wiki.debian.org/NvidiaGraphicsDrivers#non-free
(I used the debian specific method)

Unfortunately there are problems with the current debian package from Nvidia (version 169.09). It has a conflict with the X server of lenny.

The older version (1.0.8776) will produce compiler error with kernel 2.6.23 and newer.

So I made a patch for version 1.0.8776 that it compiles with newer kernels.

* Install nvidia-glx_1.0.8776-4_i386.deb, nvidia-kernel-source_1.0.8776-4_i386.deb,

This will install a source tarball in /usr/src/nvidia-kernel-source.tar.gz. Unpack it in /usr/src. For example, to unpack the source tarball of the current driver:
$ cd /usr/src
# tar -zxf nvidia-kernel-source_1.0.8776-4_i386.tar.gz

* Apply patch below:
Copy everything below "------------------" into a file (e.g. nvpatch)
cd to /usr/lib/modules where the proprietary extension nvidia-kernel is located
patch -p1 < nvpatch

* Build the kernel and the nvidia kernel module:
$ cd /usr/src/linux
# make-kpkg clean
# make-kpkg kernel_image modules_image

* Install the new kernel and kernel module:
$ cd /usr/src
# dpkg -i /path/kernel-image-*.deb /path/nvidia-kernel-*.deb

-------------------------------------------------------------------
diff -Nru modules/nvidia-kernel/nv/nv-linux.h modules_lennypatch/nvidia-kernel/nv/nv-linux.h
--- modules/nvidia-kernel/nv/nv-linux.h 2007-01-05 04:51:29.000000000 +0000
+++ modules_lennypatch/nvidia-kernel/nv/nv-linux.h 2008-03-09 15:01:46.000000000 +0000
@@ -31,6 +31,16 @@
# error This driver does not support development kernels!
#endif

+// #include "conftest.h"
+
+// #if defined(KERNEL_2_4)
+#if 1
+#define NV_KMEM_CACHE_CREATE_PRESENT
+#define NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT 6
+#define NV_IRQ_HANDLER_T_TAKES_PTREGS
+#endif
+
+
#if defined (CONFIG_SMP) && !defined (__SMP__)
#define __SMP__
#endif
@@ -506,17 +516,40 @@
free_pages(ptr, order); \
}

+/*
#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \
{ \
kmem_cache = kmem_cache_create(name, sizeof(type), \
0, 0, NULL, NULL); \
}
+*/

+#if defined(NV_KMEM_CACHE_CREATE_PRESENT)
+#if (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 6)
+// taken
+#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \
+ { \
+ kmem_cache = kmem_cache_create(name, sizeof(type), \
+ 0, 0, /* NULL, */ NULL); \
+ }
+#elif (NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT == 5)
+#define NV_KMEM_CACHE_CREATE(kmem_cache, name, type) \
+ { \
+ kmem_cache = kmem_cache_create(name, sizeof(type), \
+ 0, 0, NULL); \
+ }
+#else
+//#error "NV_KMEM_CACHE_CREATE_ARGUMENT_COUNT value unrecognized!"
+#endif
#define NV_KMEM_CACHE_DESTROY(kmem_cache) \
{ \
kmem_cache_destroy(kmem_cache); \
kmem_cache = NULL; \
}
+#else
+//#error "NV_KMEM_CACHE_CREATE() undefined (kmem_cache_create() unavailable)!"
+#endif
+

#define NV_KMEM_CACHE_ALLOC(ptr, kmem_cache, type) \
{ \
diff -Nru modules/nvidia-kernel/nv/nv.c modules_lennypatch/nvidia-kernel/nv/nv.c
--- modules/nvidia-kernel/nv/nv.c 2007-01-05 04:51:29.000000000 +0000
+++ modules_lennypatch/nvidia-kernel/nv/nv.c 2008-03-09 15:06:24.000000000 +0000
@@ -99,7 +99,8 @@
int nv_use_cpa = 1;
#endif

-static kmem_cache_t *nv_pte_t_cache = NULL;
+// V8776: static kmem_cache_t *nv_pte_t_cache = NULL;
+static void *nv_pte_t_cache = NULL;

// allow an easy way to convert all debug printfs related to events
// back and forth between 'info' and 'errors'
@@ -1453,8 +1454,9 @@
if (apm_nv_dev[i] != NULL) pm_unregister(apm_nv_dev[i]);
#endif

- if (unregister_chrdev(nv_major, "nvidia") < 0)
- nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
+ /* if (unregister_chrdev(nv_major, "nvidia") < 0) */
+ // nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
+ unregister_chrdev(nv_major, "nvidia");

for (i = 0; i < num_nv_devices; i++)
{
@@ -1478,8 +1480,9 @@

nv_printf(NV_DBG_INFO, "NVRM: nvidia_exit_module\n");

- if (unregister_chrdev(nv_major, "nvidia") < 0)
- nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
+ /* if (unregister_chrdev(nv_major, "nvidia") < 0) */
+ // nv_printf(NV_DBG_ERRORS, "NVRM: unregister nv chrdev failed\n");
+ unregister_chrdev(nv_major, "nvidia");

for (i = 0; i < num_nv_devices; i++)
{

Matt said...

This worked great! Other methods failed for me.

kimberly said...

My computer was attacked by a virus and when i bought it, i missed the drivers, so i needed to looking information by internet. Finally i reached an information that advised me download by the web. i was surprised. I hink all the information cotained in the blogs always result very useful. actually i found a site interesting called costa rica investment opportunities