# Is installing nvidia drivers with `pkg install nvidia-driver` officially best practice?



## badasahog (Sep 8, 2022)

Popular FreeBSD content creator RoboNubbie posted a video walkthrough for installing and configuring FreeBSD in which he details the way in which you should install nvidia drivers (



_View: https://www.youtube.com/watch?v=XjPha2bWvxs_
)

He advises to use `pkg search nvidia`, and then pick out the driver that works for your card.

Because I didn't know which driver to install I posed the question on stackoverflow sister website superuser.com (link: https://superuser.com/questions/1740564/how-do-i-know-which-nvidia-driver-to-install-for-freebsd)

There I was informed that I should instead install using `pkg install nvidia-driver` instead of search through a list of drivers.

Yet another person commented that I should download and install the gpu drivers from the official nvidia website.

What approach is considered best practice?

Please provide proof from within the FreeBSD documentation or other official material if possible


----------



## zirias@ (Sep 8, 2022)

badasahog said:


> There I was informed that I should instead install using `pkg install nvidia-driver` instead of search through a list of drivers.


Yes. Either that or some older version (`nvidia-driver-xxx`) if you own some older GPU that's not supported any more in the most recent version.


badasahog said:


> Yet another person commented that I should download and install the gpu drivers from the official nvidia website.


That's *not* recommended at all. Not only would that circumvent `pkg`, so you'd have no control over the files it installed, it also does problematic things like just replacing libraries installed by other packages.

The official FreeBSD ports/packages just repackage original nvidia drivers in a clean way.


----------



## mer (Sep 8, 2022)

Having a system with nvidia gpu and discussions with lots of folks, I  agree with zirias@ "You do not want to install from NVIDIA website UNLESS you are the port maintainer and working through updating the port".

I've alway done pkg install of the correct version.
The correct version is the trick:  It depends on the exact GPU you are using.
pkg install nvidia-driver will typically install just about the latest version from Nvidia.  Currently, I think it's v510.
BUT (big but here):
Nvidia routinely drops support for what they consider older GPUs when they release a new version, so if you install nvidia-driver, get 510 but have an older GPU that may not be the right version.  I ran into that.
That's why if you do pkg search nvidia-driver you see packages for 
510, 470, 390, 340 and 304.
Figure out which version is appropriate for your specific hardware (that's where the nvidia website comes in handy to me) and install that.  Alot of "which version" depends on the pci id of the GPU.

Proof from official documentation is go look in the ports tree, the Makefile for nvidia-driver and see what version it calls out.


----------



## kpedersen (Sep 8, 2022)

badasahog said:


> Please provide proof from within the FreeBSD documentation or other official material if possible


Proof is that the handbook describes the ports/packages method and completely ignores the upstream tarball from NVIDIA's site:

https://docs.freebsd.org/en/books/handbook/x11/#x-config-video-cards

Grabbing the drivers from upstream is an old fashioned "Windows-centric" consumer approach. Computers are more varied and complex than that once you step outside the box (which admittedly 99% of people don't tend to).

That said, the handbook also doesn't mention the kldload / kld_list of `nvidia-modeset` (and `nvidia`). The handbook still needs some work here. However do note that if you install the package, you will be given these instructions on-screen.

Edit: This section seems to be mislabeled and also a little bit out of date but does detail the nvidia card setup specifically:

https://docs.freebsd.org/en/books/handbook/x11/#x-compiz-video-card


----------



## mer (Sep 8, 2022)

kpedersen said:


> Edit: This section seems to be mislabeled and also a little bit out of date but does detail the nvidia card setup specifically:


Yep especially with newer X doing lots dynamically and only need some "stub" files.  We've got examples in this forum for that.

Hmm.  maybe someone should write a docs bug/patch or something with updated information.


----------



## kpedersen (Sep 8, 2022)

There are a few bits that could do with improving:

https://cgit.freebsd.org/doc/blame/documentation/content/en/books/handbook/x11/_index.adoc

Currently just looking into some quick AsciiDoc related tools and might submit some changes:

https://docs.freebsd.org/en/books/fdp-primer/asciidoctor-primer/

This X11 part of the handbook has been rather messy for a while. It never really caught up since the LinuxKPI / KMS part was introduced.


----------



## mer (Sep 8, 2022)

kpedersen said:


> This X11 part of the handbook has been rather messy for a while. It never really caught up since the LinuxKPI / KMS part was introduced.


Yep.  That's why this forum gets riled up when someone says "follow the handbook", then jumps in "but the handbook is wrong", blah blah blah 

SirDice posted something within the last 5 days about the code snippet for an X config stub for nvidia;  that should make it into the handbook instead of the "modify the xorg.conf file".


----------



## zirias@ (Sep 8, 2022)

kpedersen said:


> Currently just looking into some quick AsciiDoc related tools


For working on the doc repo, install metaport textproc/docproj, it depends on everything needed for a full build.


----------



## badasahog (Sep 8, 2022)

Is it `pkg install nvidia-driver` or `pkg install x11/nvidia-driver`?


----------



## mer (Sep 8, 2022)

badasahog said:


> Is it `pkg install nvidia-driver` or `pkg install x11/nvidia-driver`?


"Yes"
either one works.  the port lives in /usr/ports/x11/nvidia-driver, but when you are doing pkg install nvidia-driver gets to the same point.


----------

