# HowTo ? installation FreeBSD 13 on laptop with GPU Nvidia/Intel, need only Nvidia (Prime)



## dahikino (Jun 30, 2021)

Hello,
I try to install FreeBSD 13 current/stable for first time on my laptop MSI (GP75 Leopard 9SD) but Xorg si not detecting my display. i Have the internal display and the external display on DP port.
I installed Xorg and Xfce, i did add in rc.conf the line kld_list="nvidia", the module nvidia/nvidia-modeset are loaded but.

No one display is detected, i would like to use only nvidia GPU in PRIME, it means i don't care about intel GPU.

I don't find a way to solve my problem of display and i don't find a guide that make it easy.
Sincerally, Xorg is really a shit about auto detection configuration, coming from Arch Linux.

I copied the files .conf about Xorg from my working Arch Linux system but no way.

Need help 

Best Regards.


----------



## SirDice (Jun 30, 2021)

dahikino said:


> I try to install FreeBSD 13 current/stable


Please refrain from using 'current' or 'stable' labels, those have specific meaning with regards to FreeBSD versions. Now we don't know if you mean 13.0-CURRENT, 13.0-STABLE or 13.0-RELEASE. 



dahikino said:


> I don't find a way to solve my problem of display and i don't find a guide that make it easy.


Handbook: 5.4. Xorg Configuration



dahikino said:


> add in rc.conf the line `kld_list="nvidia"`,


Modern NVidia cards usually require `kld_list="nvidia-modeset"`.



dahikino said:


> I copied the files .conf about Xorg from my working Arch Linux system but no way.


Remove them, all of it.

Only add /usr/local/etc/X11/xorg.conf.d/drivers-nvidia.conf:

```
Section "Device"
        Identifier "Card0"
        Driver     "nvidia"
EndSection
```


----------



## dahikino (Jun 30, 2021)

SirDice said:


> Please refrain from using 'current' or 'stable' labels, those have specific meaning with regards to FreeBSD versions. Now we don't know if you mean 13.0-CURRENT, 13.0-STABLE or 13.0-RELEASE.
> 
> 
> Handbook: 5.4. Xorg Configuration
> ...


i use FreeBSD 13.0 stable.


----------



## monwarez (Jun 30, 2021)

If you follow the latest branch of pkg (section 4.4.2 https://docs.freebsd.org/en/books/handbook/ports/#pkgng-intro ), you can install

x11/nvidia-hybrid-graphics

And then as root
`sysrc nvidia_xorg_enable="YES"`

Remove all the xorg configuration.

You will most likely need the intel 3D acceleration so install the driver
graphics/drm-kmod

And then as root
`sysrc kld_list +=" i915kms"`

With this configuration, your desktop environment will use the intel card for 2D and 3D.

When you need to launch a 3D application on the nvidia cards
`nvrun-vgl my3Dapplication`

For the moment, there is no real PRIME support for switching between the two gpu (they live in a separate Xorg server)
Here  some exemple of my xrandr providers

```
xrandr --listproviders

Providers: number : 1
Provider 0: id: 0x48 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 4 outputs: 5 associated providers: 0 name:Intel

env DISPLAY=:8 xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x1b8 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:NVIDIA-0
```


----------



## bsduck (Jun 30, 2021)

x11/nvidia-xconfig may be useful.


----------



## mr8ash (Jul 1, 2021)

monwarez said:


> If you follow the latest branch of pkg (section 4.4.2 https://docs.freebsd.org/en/books/handbook/ports/#pkgng-intro ), you can install
> 
> x11/nvidia-hybrid-graphics
> 
> ...


this is my xrand providers

xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x46 cap: 0xa, Sink Output, Sink Offload crtcs: 3 outputs: 4 associated providers: 0 name:modesetting

but when i run nvrun-vgl glxgears, i get ld-elf.so.1: /usr/local/lib/libGL-NVIDIA/libGL.so.1: mmap of data failed: Permission denied
how do i solve it?


----------



## monwarez (Jul 1, 2021)

Does running `nvidia-settings` works ?
Also what is the output of: `pkg info nvidia-secondary-driver` ?
Does this happen with a RELEASE version ? If not you should ask on the stable mailing list about this issue.


----------



## shkhln (Jul 1, 2021)

dahikino said:


> No one display is detected, i would like to use only nvidia GPU in PRIME, it means i don't care about intel GPU.


Well, you can't. Or, more precisely, you need 2 GPUs for PRIME offloading.


----------



## shkhln (Jul 1, 2021)

monwarez said:


> For the moment, there is no real PRIME support for switching between the two gpu (they live in a separate Xorg server)


There is some support* for http://download.nvidia.com/XFree86/Linux-x86_64/470.42.01/README/primerenderoffload.html, but not for http://download.nvidia.com/XFree86/Linux-x86_64/470.42.01/README/randr14.html.


Spoiler



* if you happen to have the same set of driver patches as I do


----------



## monwarez (Jul 1, 2021)

Since mesa use graphics/libglvnd, the nvidia driver should not install the libGL.so.1 (for the non legacy driver of course), at least it is the case on my system.
shkhln how do you manage to setup prime offloading ? Are you using your patch from https://github.com/shkhln/revird-aidivn ? Or it is some secret patch ?


----------



## mr8ash (Jul 1, 2021)

monwarez said:


> Does running `nvidia-settings` works ?
> Also what is the output of: `pkg info nvidia-secondary-driver` ?
> Does this happen with a RELEASE version ? If not you should ask on the stable mailing list about this issue.


I did not install nvidia-settings. I uninstalled the nvidia-hybrid-graphics-390-0.5 and nvidia-secondary-driver-390-390.143_1 and installed nvidia-hybrid-graphics-0.5.
pkg info nvidia-secondary-driver
nvidia-secondary-driver-460.80_1
Name           : nvidia-secondary-driver
Version        : 460.80_1
Installed on   : Thu Jul  1 22:06:34 2021 +08
Origin         : x11/nvidia-secondary-driver
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : x11 kld
Licenses       : NVIDIA
Maintainer     : theron.tarigo@gmail.com
WWW            : https://www.nvidia.com/object/unix.html
Comment        : NVidia graphics card binary drivers for hardware OpenGL rendering on secondary device
Options        :
    ACPI_PM        : off
    DOCS           : on
    LINUX          : on
    WBINVD         : off
Shared Libs required:
    libXext.so.6
    libX11.so.6
Shared Libs provided:
    libGLX_nvidia.so.0
    libnvidia-ml.so.1
    libnvidia-eglcore.so.1
    libvdpau_nvidia.so.1
    libnvidia-glsi.so.1
    libnvidia-cfg.so.1
    libEGL_nvidia.so.0
    libGLESv2_nvidia.so.2
    libGLESv1_CM_nvidia.so.1
    libnvidia-glcore.so.1
    libnvidia-tls.so.1
Annotations    :
    FreeBSD_version: 1300139
    repo_type      : binary
    repository     : FreeBSD
Flat size      : 173MiB
Description    :
These are the official NVidia binary drivers for hardware OpenGL rendering
in X11, using the GLX extensions.

WWW: https://www.nvidia.com/object/unix.htm
Now when I run nvrun-vgl glxgears, it seems to be running, but it is nowhere to be found on the screen.


----------



## shkhln (Jul 1, 2021)

monwarez said:


> shkhln how do you manage to setup prime offloading?


I used this config for testing:


Spoiler





```
Section "ServerLayout"
  Identifier "whatever"
  Screen     0 "iGPU"
  Screen     1 "dGPU"
EndSection

Section "Device"
  Identifier "iGPU-dev"
  Driver     "modesetting"
  BusID      "PCI:0:2:0"
EndSection

Section "Device"
  Identifier "dGPU-dev"
  Driver     "nvidia"
  BusID      "PCI:1:0:0"
EndSection

Section "Monitor"
  Identifier "iGPU-dsp"
EndSection

Section "Monitor"
  Identifier "dGPU-dsp"
EndSection

Section "Screen"
  Identifier "iGPU"
  Device     "iGPU-dev"
  Monitor    "iGPU-dsp"
EndSection

Section "Screen"
  Identifier "dGPU"
  Device     "dGPU-dev"
  Monitor    "dGPU-dsp"
EndSection
```



I think it could be trimmed a bit more, though. In general, you only need to do whatever you need to do to keep Nvidia's Xorg driver from unloading.



monwarez said:


> Are you using your patch from https://github.com/shkhln/revird-aidivn ?


That patch, yes.


----------

