# How to install NVIDIA Drivers from official site



## Daniel S. Lobo (Mar 6, 2016)

How to install NVIDIA Drivers downloaded from official site.

I decided to write this tutorial because I did not find any documentation to install the Nvidia driver downloaded directly from the site. NVIDIA's instructions about this are not enough. The reason for this is that the official driver is more updated.

Download the nvidia driver:

```
$ cd ~/Downloads
$ fetch http://us.download.nvidia.com/XFree86/FreeBSD-x86_64/361.28/NVIDIA-FreeBSD-x86_64-361.28.tar.gz
```
Download your current kernel source:

```
$ cd ~/Downloads
$ fetch ftp://ftp.freebsd.org/pub/`uname -s`/releases/`uname -m`/`uname -r`/src.txz
```
Login with root user and execute this to decompress kernel source on the right place:

```
# tar -C / -xzvf src.txz
```
Decompress and install nvidia driver:

```
# tar -vxzf NVIDIA-FreeBSD-x86_64-361.28.tar.gz
# cd NVIDIA-FreeBSD-x86_64-361.28
# make install
```
In theory the installation script Nvidia make all configuration, but in my case, I use UEFI, so I had problems with nvidia modules load drivers at boot. If this is your case, before restart follow the steps below:

Install Nano, like root (It's more easy to use):

```
# pkg install nano
```
Open the file /boot/loader.conf

```
# nano /boot/loader.conf
```
Comment (recommend) or delete all entry from Nvidia to disable them:

```
#nvidia_load="YES"
#nvidia_name="nvidia"
#nvidia_modeset_load="YES
#nvidia_modeset_name="nvidia-modeset"
```
Save with CTRL + O and exit with CTRL + X.

Now open the file /etc/rc.conf

```
# nano /etc/rc.conf
```
And add these lines:

```
### Nvidia Boot Settings ###
kld_list="nvidia nvidia-modeset"
nvidia_name="nvidia"
nvidia_modeset_name="nvidia-modeset"
```
Save with CTRL + O and exit with CTRL + X.

I'm not sure if this file works by the order of entries, as I am new to FreeBSD, then I recommend that you put these entries before the lines that carry the GDM and Gnome, or any other X Manager installed. Correct me if I'm wrong.

At last, execute the command below to generate the file /etc/X11/xorg.conf with Nvidia config:

```
# nvidia-xconfig
```
Reboot the system and be happy.

Sorry about my bad English.


----------



## protocelt (Mar 6, 2016)

I sincerely appreciate the time you took to write this up but it's not a good idea to install the Nvidia driver from Nvidia's website. The Nvidia driver port (x11/nvidia-driver) has been patched by the port maintainer to install and update cleanly. When installing the driver from Nvidia's website, what will likely happen is the first time you attempt to update your system or Xorg, you will not longer be able to access the desktop. The reason being is the driver from Nvidia's website overwrites existing files from your installation and replaces them with Nvidia specific files. When you update, those files will then be replaced with the previous versions of the files and the Nvidia driver will cease to function preventing you from using X any longer.

It is much better to wait until the port is updated then to install the driver from the website.


----------



## SirDice (Mar 7, 2016)

protocelt said:


> It is much better to wait until the port is updated then to install the driver from the website.


If you want a quick solution, or if you're trying the new driver to see  if it works, just edit the port's Makefile and change the version numbers. Then run `make makesum`. After that you can build the port as usual. If the adjusted port works you can use the info to submit a patch to get the main port updated.

That way you can keep the registrations for packages and can more easily keep track of the versions. It'll also help others who also would like to have an updated driver.


----------



## protocelt (Mar 7, 2016)

SirDice said:


> If you want a quick solution, or if you're trying the new driver to see  if it works, just edit the port's Makefile and change the version numbers. Then run `make makesum`. After that you can build the port as usual. If the adjusted port works you can use the info to submit a patch to get the main port updated.
> 
> That way you can keep the registrations for packages and can more easily keep track of the versions. It'll also help others who also would like to have an updated driver.


Yes, this works, though not with the newest available Nvidia driver versions. 

If you are really feeling adventurous, you could apply the patch for Nvidia driver version 355.11 from PR 201340, comment #21. I've been testing this driver version and it does work though there are still problems switching back to the console when using UEFI for me. Nvidia driver version 361.28 supposedly has some improvements for this but unfortunately the driver has issues according to the PR and I haven't tried it myself.


----------



## dave-570 (Dec 18, 2016)

protocelt said:


> I sincerely appreciate the time you took to write this up but it's not a good idea to install the Nvidia driver from Nvidia's website. The Nvidia driver port (x11/nvidia-driver) has been patched by the port maintainer to install and update cleanly. When installing the driver from Nvidia's website, what will likely happen is the first time you attempt to update your system or Xorg, you will not longer be able to access the desktop. The reason being is the driver from Nvidia's website overwrites existing files from your installation and replaces them with Nvidia specific files. When you update, those files will then be replaced with the previous versions of the files and the Nvidia driver will cease to function preventing you from using X any longer.
> 
> It is much better to wait until the port is updated then to install the driver from the website.


I used the code from the NVidia website and built it and it works with no problems, just a heads up. I have FreeBSD-11 installed and I had to buy a PNY card with the NVidia chip set Gforce-710. FreeBSD would NOT see my Intel-Q35 graphics card, other than the standard VGA mode.


----------



## aragats (Feb 2, 2017)

protocelt said:


> it's not a good idea to install the Nvidia driver from Nvidia's website. The Nvidia driver port (x11/nvidia-driver) has been patched by the port maintainer to install and update cleanly


If the driver from Nvidia website is already installed, is it a good idea to install one from the port? In other words: is it safe to do?
The reason I'm asking is that I have issues with mine.


----------



## SirDice (Feb 2, 2017)

aragats said:


> If the driver from Nvidia website is already installed, is it a good idea to install one from the port?


No. I would suggest removing the NVidia driver and always use the port/package. That's the only way the system can keep track of installed files.



> In other words: is it safe to do?


No, the system doesn't know you installed something outside of the ports/package system. So it simply assumes there's nothing installed and will overwrite the existing files without cleaning up.


----------



## aragats (Feb 2, 2017)

SirDice said:


> the system doesn't know you installed something outside of the ports/package system


Do you mean that I should not install the driver from FreeBSD port without uninstalling the one from Nvidia web site? But if the later has already overwritten some files, wouldn't its uninstallation be more harmful?


----------



## SirDice (Feb 2, 2017)

And this is exactly the reason why you should always use the port or package. Because you will inevitably end up clobbering something.


----------



## dave-570 (Apr 14, 2017)

protocelt said:


> I sincerely appreciate the time you took to write this up but it's not a good idea to install the Nvidia driver from Nvidia's website. The Nvidia driver port (x11/nvidia-driver) has been patched by the port maintainer to install and update cleanly. When installing the driver from Nvidia's website, what will likely happen is the first time you attempt to update your system or Xorg, you will not longer be able to access the desktop. The reason being is the driver from Nvidia's website overwrites existing files from your installation and replaces them with Nvidia specific files. When you update, those files will then be replaced with the previous versions of the files and the Nvidia driver will cease to function preventing you from using X any longer.
> 
> It is much better to wait until the port is updated then to install the driver from the website.


That may be true, but I have been using the website download now for about 6 months and have found NO problems !!!!


----------



## SirDice (Apr 14, 2017)

dave-570 said:


> That may be true, but I have been using the website download now for about 6 months and have found NO problems !!!!


I've used the port for the past 15 years and found no problems. Why aren't you using it?


----------



## TheRaven (Jun 1, 2017)

Cool stuff; prefer the "commercial" drivers as I bought the hardware for a reason. I do appreciate freeware and open source, but I do not accept license terms for other's ego issues. The newer NVidia cards have phenomenal drivers and when used offer pretty decent performance and visuals for systems besides Windows. Native drivers are another reason to migrate OSS tasks committing resources to a BSD distro.

Will be trying this stuff out very soon. Thanks for taking the time and shedding light on the matter.

_CUDA developer libraries are floating around now too --awesome. Don't know if they're in ports or not, but imagine they'll be there soon enough._


----------



## drhowarddrfine (Jun 1, 2017)

TheRaven CUDA developer libraries work on FreeBSD. Just saw an article about that a few weeks ago somewhere.


----------



## debguy (Jun 26, 2018)

The nVidia drivers page on nVidia's website say "supports X11 and xorg"

However i've downloaded them: they have hacked out X11 support and include ONLY xorg support


----------



## debguy (Jun 26, 2018)

yes nVidia drivers hose your /usr/X11/lib/modules and etc

back them up first

but i disagree if you upgrade it may or may not be harm done.  if you upgrade you may or may not be able to re-install the same nVidia driver.  in then end if there's "a bad file" you'll find it.  but doubtful since if you upgrade it'll be overwritten (we're freebsd here not debian!).  and files not overwritten are likely not gonna be used by the upgrade system.  what might *not* work is if nVidia's driver doesnt' like your libs - but they tell you if they will before you download and they're likely right

and i disagree that xorg drivers "are better than nVidia's original release but correct for your system".  in the past xorg was infamous for bad drivers esp. intel ones.  people who used drivers off nVidia site had far less problems AND BINARY BLOBS that "worked" (non-free of course).

that may be less true today of course, perhaps all xorg does today is copy off nVidia releases or perhaps the same bloke actually works both positions now


----------



## faysal76 (Jan 30, 2019)

Thanks Daniel, Nice guidelines, its also worked with nvidia-driver provided through ports.


----------



## tedbell (Jun 16, 2019)

Does this still work? I keep getting errors concerning "stdarg.h". I need at least the 430 driver for my 16xx series card.


----------



## Phishfry (Jun 16, 2019)

tedbell said:


> I need at least the 430 driver for my 16xx series card.


That is an old driver for that card. It is legacy driver. I am pretty sure you want current for the 16xx


			FreeBSD-11.2 with NVidia drivers
		


`nano` used for a How-To
How enlightening.


----------



## tedbell (Jun 16, 2019)

Wow. It's like I just said that and you're repeating it back to me for posterity! 
Ports and pkg only has 390.xx


----------



## rigoletto@ (Jun 16, 2019)

PR 232645


----------



## Criosphinx (Jun 16, 2019)

You can try with the patches at PR 232645 for driver version 430.26


----------



## tedbell (Jun 16, 2019)

sweet thanks guys


----------



## Phishfry (Jun 16, 2019)

Sorry I got my versions mixed up.
Was thinking 'why is he using 340' for a current card.


----------



## tedbell (Jun 16, 2019)

Phishfry said:


> Sorry I got my versions mixed up.
> Was thinking 'why is he using 340' for a current card.


np. Just working out installing this patch. Thanks


----------



## tedbell (Jun 16, 2019)

Hmm. Patch works but install fails due to missing GL libraries in the work folder. Not sure if it has something to so with libglvnd which doesn't exist but there's a patch for it. Guess I'll wait for an official port.


----------



## shkhln (Jun 16, 2019)

tedbell said:


> Hmm. Patch works but install fails due to missing GL libraries in the work folder.



What exactly fails?



tedbell said:


> Not sure if it has something to so with libglvnd which doesn't exist but there's a patch for it.



Libglvnd is bundled with the driver.


----------



## tedbell (Jun 16, 2019)

shkhln said:


> What exactly fails?
> 
> 
> 
> Libglvnd is bundled with the driver.



I get this error when I make install clean:


```
~$ cd /usr/ports/x11/nvidia-driver
nvidia-driver$ sudo make install clean                                        
Password:
===>  Installing for nvidia-driver-390.87_3
===>  Checking if nvidia-driver is already installed
===>   Registering installation for nvidia-driver-390.87_3
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libEGL_nvidia.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLESv2_nvidia.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLESv2_nvidia.so.2:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLX.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLX.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLX_indirect.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLX_nvidia.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLX_nvidia.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLdispatch.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libGLdispatch.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libOpenGL.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/libOpenGL.so.0:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/share/glvnd/egl_vendor.d/10_nvidia.json:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/xorg/modules/extensions/.nvidia/libglxserver_nvidia.so:No such file or directory
pkg-static: Unable to access file /usr/ports/x11/nvidia-driver/work/stage/usr/local/lib/xorg/modules/extensions/.nvidia/libglxserver_nvidia.so.1:No such file or directory
*** Error code 74

Stop.
make[1]: stopped in /usr/ports/x11/nvidia-driver
*** Error code 1

Stop.
make: stopped in /usr/ports/x11/nvidia-driver
```


----------



## shkhln (Jun 16, 2019)

tedbell said:


> ```
> nvidia-driver-390.87_3
> ```



How did you apply the patch?


----------



## tedbell (Jun 16, 2019)

shkhln said:


> How did you apply the patch?



I downloaded the .patch file and then ran 
	
	



```
patch < patchname.patch
```
. It then asked me for a location for certain files which I entered and the patch succeeded.


----------



## shkhln (Jun 16, 2019)

Clean up the mess and reapply the patch with `patch -p1 < whatever-path/nvidia-driver-430.26.patch`. You need to run this command from the root directory of the ports tree (/usr/ports in your case).


----------



## tedbell (Jun 16, 2019)

shkhln said:


> Clean up the mess and reapply the patch with `patch -p1 < whatever-path/nvidia-driver-430.26.patch`. You need to run this command from the root directory of the ports tree (/usr/ports in your case).



WOW I knew it had something to do with that patch command. Your solution worked and I am typing this from my NVIDIA card. Thanks so much. I am HUGELY grateful. No more Windows! 
Thanks everyone!


----------

