Important: You are required to change your passwords used for Gentoo services and set an email address for your Wiki account if you haven't done so. See the full announcement and Wiki email policy change for more information.

NVidia/nvidia-drivers

From Gentoo Wiki
NVidia
Revision as of 07:41, 13 February 2013 by Astaecker (Talk | contribs)

Jump to: navigation, search

nvidia is the proprietary graphics driver for nVidia graphic cards. An open source alternative is nouveau.

Introduction

The nVidia drivers in the tree are released by nVidia and are built against the Linux kernel. They contain a binary blob that does the heavy lifting for talking to the card. The drivers consist of two parts, a kernel module, and an X11 driver. Both parts are included in a single package. Due to the way nVidia has been packaging their drivers, you will need to make some choices before you install the drivers.

The nvidia-drivers package contains the latest drivers from nVidia with support for all cards, with several versions available depending on how old your card is. It uses an eclass to detect what kind of card you're running so that it installs the proper version.

Driver compatibility

Which version?

The nvidia-drivers package supports the full range of available nVidia cards. Multiple versions are available for installation, depending on the card(s) you have.

Newer cards such as the GeForce 400, 300, 200, 100, 9, 8, 7, and 6 series should use the latest drivers.

Older cards such as the GeForce FX 5 series should use the 173.x drivers, such as nvidia-drivers-173.14.36. For these cards, you should mask >=x11-drivers/nvidia-drivers-174.00 in your /etc/portage/package.mask file. This will prevent newer versions of the driver which are incompatible with your card from being installed.

Old cards such as the GeForce 3 or GeForce 4 series require the 96.x drivers. For these cards, you should mask >=x11-drivers/nvidia-drivers-97.00 in your /etc/portage/package.mask file.

The oldest NV2x-based cards (such as TNT, TNT2, GeForce, and GeForce 2) are no longer supported by nvidia-drivers. Instead, use an open-source driver: nouveau (recommended) or xf86-video-nv (old, deprecated).

You can check for driver compatibility for your card at to determine which driver supports it by viewing the README at its appropriate x86 or x86-64 release page.

Configuring your Card

Kernel Configuration

As mentioned above, the nVidia kernel driver installs and runs against your current kernel. It builds as a module, so it makes sense that your kernel must support the loading of kernel modules. If you used genkernel all to configure the kernel for you, then you're all set. If not, double check your kernel configuration so that this support is enabled:

Kernel configuration

Loadable module support --->
    [*] Enable loadable module support

You also need to enable Memory Type Range Register in your kernel:

Kernel configuration

Processor and Features --->
    [*] MTRR (Memory Type Range Register) support

Also, if you have an AGP graphics card, you can optionally enable agpgart support to your kernel, either compiled in or as a module. If you do not use the in-kernel agpgart, then the drivers will use their own agpgart implementation, called NvAGP. On certain systems, this performs better than the in-kernel agpgart, and on others, it performs worse. You will need to evaluate this on your own system to get the best performance. If you are unsure what to do, use the in-kernel agpgart:

Kernel configuration

Device Drivers --->
    Graphics Support --->
        -*- /dev/agpgart (AGP Support) --->
Note
On amd64, the IOMMU controls the agpgart setting.

Arch-specific notes

Important
For x86 and AMD64 processors, the in-kernel framebuffer driver conflicts with the binary driver provided by nVidia. If you will be compiling your kernel for these CPUs,you must completely remove support for the in-kernel driver as shown:
Kernel configuration

Device Drivers --->
    Graphics Support --->
        <*> Support for frame buffer devices --->
            < >   nVidia Framebuffer Support
            < >   nVidia Riva support

A framebuffer alternative is uvesafb, which can be installed parallel to nvidia-drivers.

Continuing with Kernel Configuration

The nvidia-drivers ebuild automatically discovers your kernel version based on the /usr/src/linux symlink. Please ensure that you have this symlink pointing to the correct sources and that your kernel is correctly configured. Please refer to the "Configuring the Kernel" section of the Gentoo Handbook for details on configuring your kernel.

First, you'll need to choose the right kernel source using eselect. If you are using gentoo-sources-3.4.9, your kernel listing might look something like this:

root # eselect kernel list
Available kernel symlink targets:
  [1]   linux-3.4.9-gentoo *
  [2]   linux-3.3.8-gentoo

In the above output, you'll notice that the linux-3.4.9-gentoo kernel is marked with an asterisk (*) to show that it is the symlinked kernel.

If the symlink is not pointing to the correct sources, you must update the link by selecting the number of your desired kernel sources, as in the example above.

root # eselect kernel set 1

Installing the Appropriate Drivers

Now it's time to install the drivers. You can do this by first following the X Server Configuration HOWTO and setting VIDEO_CARDS="nvidia" in /etc/portage/make.conf. When you install the X server, it will then install the right version of nvidia-drivers for you.

Note
The drivers can be installed with the gtk USE flag set in /etc/portage/make.conf. This will install media-video/nvidia-settings, a handy graphical tool for monitoring and configuring several aspects of your nVidia card.
Important
Every time you compile a new kernel or recompile the current one, you will need to reinstall the nVidia kernel modules. An easy way to keep track of modules installed by ebuilds (such as nvidia-drivers) is to install sys-kernel/module-rebuild. Once you've installed it, simply run module-rebuild populate to populate its database with a list of packages to be rebuilt. Once you've finished compiling or recompiling a kernel, just run module-rebuild rebuild to rebuild the drivers for your new kernel.

Once the installation has finished, run modprobe nvidia to load the kernel module into memory. If this is an upgrade, you should remove the previous module first.

root # lsmod | grep nvidia
root #
rmmod nvidia
root #
modprobe nvidia

To prevent you having to manually load the module on every bootup, you probably want to have this done automatically each time you boot your system, so edit /etc/conf.d/modules and add nvidia to it.

Important
If you compiled agpgart as a module, you will need to add it to /etc/conf.d/modules as well.

Configuring the X Server

Once the appropriate drivers are installed you need to configure your X Server to use the nvidia driver instead of the default nv driver.

Open /etc/X11/xorg.conf with your favorite editor (such as nano or Vim) and go to the Device section. In that section, change the Driver line:

File/etc/X11/xorg.confSetting the nVidia driver

Section "Device"
  Identifier "nVidia Inc. GeForce2"
  Driver     "nvidia"
EndSection

Run eselect so that the X Server uses the nVidia GLX libraries:

root # eselect opengl set nvidia

Adding your Users to the video Group

You have to add your user to the video group so he has access to the nVidia device files:

root # gpasswd -a youruser video

This might not be totally necessary if you aren't using udev but it doesn't hurt either and makes your system future-proof.

Testing your Card

To test your nVidia card, fire up X and run glxinfo, which is part of the mesa-progs package. It should say that direct rendering is activated:

user $ glxinfo | grep direct
direct rendering: Yes

To monitor your FPS, run glxgears.

Enabling nvidia Support

Some tools, such as mplayer and xine-lib, use a local USE flag called xvmc which enables XvMCNVIDIA support, useful when watching high resolution movies. Add in xvmc in your USE variable in /etc/portage/make.conf or add it as USE flag to media-video/mplayer and/or media-libs/xine-lib in /etc/portage/package.use.

There are also some applications that use the nvidia USE flag, so you may want to add it to /etc/portage/make.conf.

Then, run emerge -uD --newuse @world to rebuild the applications that benefit from the USE flag change.

Using NVidia Settings Tool

nVidia also provides you with a settings tool. This tool allows you to monitor and change graphical settings without restarting the X server and is available through Portage as media-video/nvidia-settings. As mentioned earlier, it will be pulled in automatically if you install the drivers with the gtk USE flag set in /etc/portage/make.conf or in /etc/portage/package.use.

Troubleshooting

Getting 2D to work on machines with 4Gb or more memory

If you are having troubles with the nVidia 2D acceleration it is likely that you are unable to set up a write-combining range with MTRR. To verify, check the contents of /proc/mtrr:

root # cat /proc/mtrr

Every line should contain "write-back" or "write-combining". If you see a line with "uncachable" in it you will need to change a BIOS setting to fix this.

Reboot and enter the BIOS, then find the MTRR settings (probably under "CPU Settings"). Change the setting from "continuous" to "discrete" and boot back into Linux. You will now find out that there is no "uncachable" entry anymore and 2D acceleration now works without any glitches.

When I attempt to load the kernel module, I receive a "no such device"

This is usually caused by one of the following issues:

1. You don't have an nVidia card at all. Check lspci output to confirm that you have an nVidia graphics card installed and detected.

2. The currently installed version of x11-drivers/nvidia-drivers does not support your graphics card model. Check the README file in /usr/share/nvidia-drivers-*/ for a list of supported devices, or use the driver search at http://www.geforce.com/drivers. See the Which Version section above.

3. Another kernel driver has control of the hardware. Check lspci -k to see if another driver like "nouveau" is bound to the graphics card. If so, you will need to disable or blacklist this driver.

Xorg says it can't find any screens

When you boot up your computer and end up with a black screen or a console prompt instead of your GUI; you can press Ctrl+Alt+F2 to bring up a console prompt if you don't already have one. Then you can run:

root # /etc/init.d/xdm stop
user $ startx

to see the output of Xorg. If one of the first errors is that Xorg can't find any screens, then follow these steps to resolve your issue.
It should be enough to run the following command before rebooting:

user $ nvidia-xconfig

But if that doesn't work, run lspci and you'll find your video card starts off like this: 01:00.0 VGA compatible controller: make and model of videocard
Take the first bit, 01.00.0 and put it in your /etc/X11/xorg.conf with the BusID option:

File/etc/X11/xorg.conf

# this is not the whole file, only the part that needs edited
# the file should already exist after running nvidia-xconfig

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection


Expert Configuration

Documentation

The nVidia driver package also comes with comprehensive documentation. This is installed into /usr/share/doc and can be viewed with the following command:

user $ less /usr/share/doc/nvidia-drivers-*/README.gz

Kernel module parameters

The nvidia kernel module accepts a number of parameters (options) which you can use to tweak the behaviour of the driver. Most of these are mentioned in the documentation. To add or change the values of these parameters, edit the file /etc/modprobe.d/nvidia.conf. Remember to run update-modules after modifying this file, and bear in mind that you will need to reload the nvidia module before the new settings take effect.

Edit /etc/modprobe.d/nvidia.conf in your favourite editor:

root # nano -w /etc/modprobe.d/nvidia.conf

Update module information:

root # update-modules

Unload the nvidia module...

root # modprobe -r nvidia

...and load it once again:

root # modprobe nvidia

Advanced X configuration

The GLX layer also has a plethora of options which can be configured. These control the configuration of TV out, dual displays, monitor frequency detection, etc. Again, all of the available options are detailed in the documentation.

If you wish to use any of these options, you need to list them in the relevant Device section of your X config file (usually /etc/X11/xorg.conf). For example, suppose I wanted to disable the splash logo:

File/etc/X11/xorg.confDisable the splash logo

Section "Device"
  Identifier "nVidia Inc. GeForce2"
  Driver     "nvidia"
  Option     "NoLogo" "true"
  VideoRam   65536
EndSection

Acknowledgements

We would like to thank the following authors and editors for their contributions to this guide: Sven Vermeulen, Joshua Saddler, M Curtis Napier and Chris Gianelloni.

See also