HOWTO: Install and configure NVIDIA drivers

FreeBSD's Ports collection contains the official NVIDIA binary drivers for hardware OpenGL rendering in X, using the GLX extensions.The x11/nvidia-driver points to NVIDIA's latest stable driver set.

If you are using a legacy card check NVIDIA's site to see which driver set supports your card and browse the Ports tree for the suitable driver version and install that instead. Do notice that there aren't any 64bit NVIDIA drivers for FreeBSD.

Bellow are the steps needed to install NVIDIA drivers on i386 FreeBSD:

Code:
% su
# portsnap fetch update
# cd /usr/ports/x11/nvidia-drivers
# make config
# make install clean
# echo 'nvidia_load="YES"' >> /boot/loader.conf
# echo 'linux_enable="YES"' >> /etc/rc.conf
# echo 'hint.agp.0.disabled="1"' >> /boot/device.hints
Basically start by updating your ports tree, installing the driver and preparing FreeBSD to load the NVIDIA kernel module it at boot time. Consider selecting ACPI (enable support for ACPI Power Management) and LINUX (build with support for Linux compatibility) port options.

Now let's proceed by editing /etc/X11/xorg.conf to have it use the NVIDIA driver and add some options to increase performance.

Edit /etc/X11/xorg.conf and change the driver value from "nv" to "nvidia":

Code:
Driver "nvidia"

If your graphics card is AGP, additional performance options can be enabled, however these might affect stability. To enable Side Band Addressing and Fast Writes add the following sysctls to /etc/sysctl.conf:

Code:
# echo "hw.nvidia.registry.EnableAGPSBA=1" >> /etc/sysctl.conf
# echo "hw.nvidia.registry.EnableAGPFW=1" >> /etc/sysctl.conf
Finally:

Code:
# reboot

Additional ports of interest when configuring X with NVIDIA:
Code:
x11/nvidia-settings
x11/nvidia-xconfig

Possible workaround for crashes and blank screen problems:
Code:
# echo 'machdep.disable_mtrrs="1"' >> /boot/loader.conf

Further reading material can be found under:
http://www.freebsd.org/doc/en/books/handbook/x11.html
/usr/local/share/doc/NVDIA_GLX-1.0/
 
If you don't use any linux programs you can compile the driver without linux support. Then you also don't need to add the linuxilator.
 
Yup.

The port's default option is off to LINUX. However gamers running stuff like Enemy Territory, RTCW and UT will appreciate the option and should enable it.
 
Absolutely.. Also the linux-flashplugin needs it (which is currently the only reason why I have linux enabled).
 
Don't forget these very helpful ports:

Code:
x11/nvidia-settings       Display Control Panel for X NVidia driver
x11/nvidia-xconfig        Tool to manipulate X configuration files for the NVidia driver
 
DutchDaemon said:
Don't forget these very helpful ports:

Code:
x11/nvidia-settings       Display Control Panel for X NVidia driver
x11/nvidia-xconfig        Tool to manipulate X configuration files for the NVidia driver

Added them to the post ;)
 
well, using NVIDIA I always got "agp detected, aborting setup!"
...........
Unfortunately,
using the guide above (I think), a blank screen, sometimes with a cursor.
one cntl-alt-del and other numerous keys-- to reboot and copy the old
xorg.conf back and comment device.hints, another cntl-alt-del to reboot
after the latter caused the blank screen to recur. Now back the
way it was. (3 ideas of what is wrong here but I can only guess)
...........
4 permutations of ways to install nvidia-drivers and 100 permutations
of ways to tweak xorg.conf, maybe in a decade there will be a way to
set it up in 20 minutes or so. Happy as long as I have the browser,
cursor, and window manager running...
 
jb_fvwm2 said:
well, using NVIDIA I always got "agp detected, aborting setup!"
You can try removing device agp from your kernel config or add hint.agp.0.disabled="1" to /boot/device.hints.
 
SirDice said:
You can try removing device agp from your kernel config or add hint.agp.0.disabled="1" to /boot/device.hints.

The latter is one of the six or so modifications listed earlier
than my post, which when all are implemented, crash X on this
setup. Even if it is not nvidia-driver, the xorg.conf, or
the .hints, (guessing!) it may be an unknown overclock of the video
card, or CRT rather than LCD, or...
 
jb_fvwm2 said:
The latter is one of the six or so modifications listed earlier
than my post, which when all are implemented, crash X on this
setup. Even if it is not nvidia-driver, the xorg.conf, or
the .hints, (guessing!) it may be an unknown overclock of the video
card, or CRT rather than LCD, or...

The purpose of this corner of the forum is presenting HowTos and FAQs. I think you'd more easily solve your problems/issues in the appropriate forum support section, in this case Desktop -> X.Org.

You need to be more verbose on what is the problem, the steps you've taken so far and post helpful stuff like error messages, logs and configuration files.
 
Sorry. If you reread my post earlier, you can read
that I *maybe* could solve it, but am happy the way things are...
lack of time as always.
 
Copy of my post at DF:

I checked what your configuration tweaks do, and they don't seem to be very useful:

tangram said:
Option "RenderAccel" "True"

According to the nVidia documentation:

Code:
Option "RenderAccel" "boolean"

    Enable or disable hardware acceleration of the RENDER extension. Default:
    hardware acceleration of the RENDER extension is enabled.


tangram said:
Option "NoRenderExtension" "boolean"

As I understand it, this option is not needed, and is useful mostly for disableing the RENDER extension, not for explicitly enabling it (It is always enabled if the X server supports it), from the nVidia documentation:

Code:
Option "NoRenderExtension" "boolean"
    Disable the RENDER extension. Other than recompiling it, the X server does
    not seem to have another way of disabling this. Fortunately, we can
    control this from the driver so we export this option. This is useful in
    depth 8 where RENDER would normally steal most of the default colormap.
    Default: RENDER is offered when possible.


tangram said:
Option "NoFlip" "False"

Again, as I understand it this option is always enabled if supported, from the nVidia documentation:

Code:
Option "NoFlip" "boolean"

    Disable OpenGL flipping]

   o Flipping: When OpenGL flipping is enabled, OpenGL can perform buffer
     swaps by changing which buffer the DAC scans out rather than copying the
     back buffer contents to the front buffer; this is generally a much higher
     performance mechanism and allows tearless swapping during the vertical
     retrace (when __GL_SYNC_TO_VBLANK is set). The conditions under which
     OpenGL can flip are slightly complicated, but in general: on GeForce or
     newer hardware, OpenGL can flip when a single full screen unobscured
     OpenGL application is running, and __GL_SYNC_TO_VBLANK is enabled.
     Additionally, OpenGL can flip on Quadro hardware even when an OpenGL
     window is partially obscured or not full screen or __GL_SYNC_TO_VBLANK is
     not enabled.


tangram said:
Option "UseEdid" "True"

Enabled by default, no reason to set it, from the nVidia documentation:

Code:
Option "UseEDID" "boolean"

    By default, the NVIDIA X driver makes use of a display device's EDID, when
    available, during construction of its mode pool. The EDID is used as a
    source for possible modes, for valid frequency ranges, and for collecting
    data on the physical dimensions of the display device for computing the
    DPI (see Appendix I). However, if you wish to disable the driver's use of
    the EDID, you can set this option to False:
    
        Option "UseEDID" "FALSE"
    
    Note that, rather than globally disable all uses of the EDID, you can
    individually disable each particular use of the EDID]


[quote="tangram"]Option "NvAGP" "1"[/quote]

Again, this is the default, nVidia documentation:

[code]When built with support for the FreeBSD AGP driver, 'nvidia.ko' will fall back
to using NvAGP when it doesn't detect 'agp.ko' (this will be the case when
'agp.ko' does not support your AGP chipset or was explicitly disabled with
device hints).
 
@ Carpetsmoker, thanks for the input.

Yeah those are default settings. I just figured they were important enough to have on xorg.conf as remainder not to change them.
 
I'm a bit of a noob but....

tangram said:
Possible workaround for crashes and blank screen problems:
Code:
# echo 'machdep.disable_mtrrs="1"' >> /etc/boot/loader.conf

Should this not be:

Code:
# echo 'machdep.disable_mtrrs=1' >> /etc/boot/loader.conf

without the quotes?

Didn't work for me until I removed them.

Just in case anyone else is still getting those mtrr errors ;)
 
If you want your loader.conf to contain
Code:
machdep.disable_mtrrx="1"

either edit the file and add it or use # echo 'machdep.disable_mtrrs="1"' >> /boot/loader.conf.

If you # echo 'machdep.disable_mtrrs=1' >> /boot/loader.conf then your /boot/loader.conf will contain:
Code:
machdep.disable_mtrrs=1

In the how to I suggested the quotes for consistency sake.
 
For nvidia-driver users who want to play linux-games with a linux_base > fc4, the solution is in [post=31198]this post[/post].
The solution should be temporary as nvidia is aware of the problem and it should be fixed in future releases of the driver.
 
My main box has an Nvidia card in it and this afternoon I finally got it working!

# pkg install xf86-video-nv --- this is a different driver than the nvidia-driver-304 and alike. With the xf86 driver in my case it doesn't need to know the exact type of the card.

make /usr/local/etc/X11/xorg.conf.d/driver-nv.conf with following content:

Code:
 Section "Device"
      Identifier "Card0"
      Driver     "nv"
 EndSection

and your display should work using the more basic Nvidia driver -- see https://lwn.net/Articles/380704/ on this driver.

Maybe not suitable for gaming or heavy graphical stuff (I didn't try), but your display is nice and smooth!
 
Back
Top