Some of the official FreeBSD write ups on using Nvidia seem to be out of date or missing information. As questions about it often come up on FreeBSD forums, I thought I'd put up this page.
Often, if you install nvidia drivers with pkg, you'll find that after restarting X or Wayland, it doesn't work properly, either not starting at all, or just using some odd resolution, like using 1024x768 when it normally uses 2560x1440.
I have a GT 1030 card. If one looks at the /usr/ports/UPDATING entry for 202060327, there is a notice that
nvidia drivers are upgraded to the latest production branch and that you can find still supported cards
by checking the list here.
Looking at that page, I see that my GT 1080 is considered a legacy card. There's a section that says, Below are the legacy GPU's that are no longer supported in the
unified driver. These GPUs will continue to be maintained through the special legacy NVIDIA GPU driver releases. The 580.xx driver supports the following set of
GPUs:
and then there's a list of those cards, beginning with the Geoforce 830M. My GT 1030 card is in that list.
If your card is in that section, it means you should download the 580 drivers and kmods. Sometimes, using pkg, this works without problems. Other times, as mentioned above, you can't restart X or the resolution is all wrong.
If you run
pkg info -D nvidia-driver-580 |
(or, if using a newer card, just pkg info -D nvidia-driver), you'll see the message that you should load the modules in /etc/rc.conf, by adding
| kld_list="nvidia-drm" |
to /etc/rc.conf. I also add
hw.nvidiadrm.modset=1 |
to /boot/loader.conf. That bit is not required and I've found mention that at times it can cause problems, but I've not been able to find where I saw that. So, all I can say is that in my experience, it hasn't caused me any problems and I have also seen articles recommending it.
Generally, when I read about problems with Nvidia drivers, it's from people who used packages to upgrade. On FreeBSD forums there are several threads about it, and most of the time, I've found that my solution works, though lately, I've only tried it on the legacy card I mentioned.
So, now when I see that running pkg upgrade will upgrade Nvidia drivers, I first backup the boot environment, using bectl. It's simple and quick, I describe it on my page about using boot environments. Now if it turns out there's a problem with the Nvidia upgrade, I can easily revert to a working system.
After doing the upgrade, I close X or Wayland (though I usually use X) and restart it to see if it went smoothly. If it hasn't gone smoothly, I then use ports.
First I make sure that I have the most current ports tree. I use gitup, so I just run gitup ports. When that is done I use portmaster. I have found that if I install nvidia-drm-66-kmod-580 and nvidia-drm-kmod-580, it will pull in any other needed Nvidia packages, such as nvidia-driver-580. Remember, I'm using the 580 version because I have an older card, those with newer cards that aren't in the legacy section of the list linked above would just use nvidia-drm-66-kmod and nvidia-kmod.
So, I run
portmaster nvidia-drm-66-kmod-580 nvidia-drm-kmod-580 |
When done (it doesn't take very long), I once again restart X to make sure it's now working properly.
In my experience, this has always fixed any problem that I've run into when updating Nvidia drivers though packages.