Nvidia Optimus Driver for FreeBSD

Theron Tarigo

Member

Reaction score: 7
Messages: 27

Thanks, looks like I should include
Code:
Option "HardDPMS" "false"
in the xorg template.

  • Having Nvidia loaded prevents suspend from working (it seems to start to suspend but bounces); having nvidia not loaded prevents it from working after suspend until a dance with acpi_call and more suspend/resumes to unstick its power state.
I discovered this was my fault, caused by some leftover devd hooks running acpi_call from when I was experimenting with ondemand Nvidia power switching.


Just tested Firefox 70.0.1 real quick. No issue so far with WebGL.
The website Shadertoy.com reliably hangs Firefox tabs after a shader page reload in Firefox 70 but not in Firefox 68.
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

How can I test nvidia hybrid graphics port ?
I have a laptop with recent intel processor (i7 gen 8th) and Nvidia dicrete GPU (1060 Max Q).
I just update my laptop to 13.0-CURRENT version
Code:
#uname -a
FreeBSD msi 13.0-CURRENT FreeBSD 13.0-CURRENT #0 8d00ce82bf9-c265417(master): Mon Dec 30 21:56:43 CET 2019     hakaba@msi:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64

I presume I have to deinstall nvidia-driver in ports, update /usr/ports/, apply path in /usr/port/x11/nvidia-driver and make install.
But maybe it exists a tools to do shis step for me ?
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

The nvidia optimus driver is available on 12.1 ? I did not find it (that is why I upgrade on 13.0-CURRENT).
 

twschulz

Member

Reaction score: 12
Messages: 34

The port is currently under review (see post #51 in this thread). So, it's not currently in the ports tree yet.

You should be able to test it on 12.1. The steps would be something like the following (just guessing, I haven't done this… yet)

1) Get the ports tree (for example by using portsnap), assuming that ends up in /usr/ports
2) Download the raw diff from reviews (D22521.diff)
3) apply the raw diff to your ports tree (cd /usr/ports && patch < D22521.diff)
4) assuming the patch applies cleanly: cd /usr/ports/x11/nvidia-hybrid-graphics && make

Keep in mind you are kind of "on your own" with this. But, you can probably add comments here or on the actual review.
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

I do it before test 13.0 but I did not have nvidia-hybrid-graphics port in /usr/ports/x11/ neither the nvidia-headless-utils mentionned in the diff file.
That is why I am lost.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,033
Messages: 38,480

Hakaba all versions of FreeBSD use the exact same ports tree.
 

twschulz

Member

Reaction score: 12
Messages: 34

I do it before test 13.0 but I did not have nvidia-hybrid-graphics port in /usr/ports/x11/ neither the nvidia-headless-utils mentionned in the diff file.
That is why I am lost.

Ah, OK. The diff creates new files (the new ports). You may need to touch those files referenced in the ports tree ahead of time and then apply the patch. You can always run patch with --dry-run to see what happens and it may give you a guide to knowing which files to touch.

Good luck!
 

Theron Tarigo

Member

Reaction score: 7
Messages: 27

I haven't been keeping up well with this, I'll check now that patches are still applicable and try to address the remaining concerns.

Firefox's problems with VirtualGL seem to have gone away, hopefully Mozilla do not reintroduce the problem but that is out of my hands.
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

Little Update for my MSI laptop :
Back in FreeBSD 12.1, I apply the patch and rebuild all from scratch.
I found a conf template in /usr/local/etc/X11/xorg.conf folder named xorg-nvidia-headless-template.conf
Without this config file, Xorg works only on the laptop screen with scfb.

With this config file, the HDMI screen receive video. The laptop screen is black with a blanc square on top left.
If I type some text in keyboard, the text appear on the laptop screen.

No error for X server, so logs do not help me.
I do not have config in /etc/X11 folder.
I change the input device config in xorg-nvidia-headless-template.conf to have a working mouse and keyboard.
 

Theron Tarigo

Member

Reaction score: 7
Messages: 27

Hi Hakaba, it sounds like your laptop is wired such that internal display uses Intel graphics, while HDMI port uses Nvidia. First be sure scfb or intel driver is working well for laptop display (your primary Xorg session should not have the nvidia driver in it). Now, if your displays are wired how I suspect, env DISPLAY=:0 xev should show a window on the laptop and env DISPLAY=:8 xev should show on the HDMI display. Is that the case?

There is not any way that I know for these two displays to share one set of input devices. A single Xorg server attached to both GPUs with PRIME would be needed for that, but PRIME is either missing or undocumented and broken on FreeBSD.
Possibly your BIOS has an option for changing the wiring of GPUs to outputs?

(These FreeBSD Optimus support drivers are only working for laptops where Intel GPU manages all displays, but if you can select Nvidia to manage all displays, then you will only need nvidia-driver package.)
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

env DISPLAY=:0 xev should show a window on the laptop and env DISPLAY=:8 xev should show on the HDMI display. Is that the case?

DISPLAY=:0 works well.
DISPLAY=:8 xev
xev: unable to open display ':8'
(With scfb on the laptop screen or nvidia in the hdmi screen)

I probably have to install Intel driver, scfb only allow 800x600 px (xrandr).

What surprise me is : if I want to use the HDMI screen without X, it is not possible ? Why the mist screen is related with X and WM and not with the system ?

With nvidia, when my HDMI screen works :
nvidia-settings
Could not open display :8

More tests tomorow...
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

Thanks. This time I can see the window on HDMI screen.
So Xev works.

env DISPLAY=:8 optirun glxgears show the gears on my HDMI screen.
Without optirun if failed.
I search a way to change the max resolution and to be sure that NVidia graphics is used (in the laptop display, I have the same perfs with glxgears and optirun glxgears).

Thanks a lot, I will be able to test this patch.
 

Theron Tarigo

Member

Reaction score: 7
Messages: 27

to be sure that NVidia graphics is used (in the laptop display, I have the same perfs with glxgears and optirun glxgears).

glxgears is not a test of overall GPU power, the limiting factor is usually the framebuffer throughput of the method used for transporting frames to the display (naturally, direct Integrated graphics typically outperforms Nvidia->Integrated proxy). FPS for an on-screen demo at or above monitor refresh rate means nearly nothing for GPU rendering power.

You can use glxinfo -B or glxgears -info to see a summary of OpenGL support including which GPU is used in that environment.
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

I have different score with glmark2 :
glmark2 487
optirun glmark2 826
env DISPLAY=:8 optirun glmark2 798

glxinfo -B show me a strange things... «OpenGL vendor string: VMWare»
optirun glxinfo -B use NVidia
 

u666sa

New Member


Messages: 9

How to start optimus service automatically?? I do have optimus_enable="YES" in rc.conf but after reboot service is not started, I have to start it manually?

Acer Aspire 5742G GeForce 420M works/
 

Theron Tarigo

Member

Reaction score: 7
Messages: 27

How to start optimus service automatically?? I do have optimus_enable="YES" in rc.conf but after reboot service is not started, I have to start it manually?

Acer Aspire 5742G GeForce 420M works/
Hi, are you using https://github.com/pouya-eghbali/freebsd-nvidia-optimus (deprecated) or https://reviews.freebsd.org/D22521 ?
For the latter, which I will try to get submitted to ports tree (I've been neglecting some little remaining issues), the service name is "nvidia_xorg".

(Currently waiting on danfe@FreeBSD.org for review)
 
Last edited:

Hakaba

Active Member

Reaction score: 121
Messages: 230

Hello, some news here...

I install the Intel graphic driver that match my CPU and use it now as default.

With glmark2, I have a very good score with Intel graphics (2350) and still 760 with the NVidia card.
That means I have an issue with the NVidia driver too (I installed the latest version for an NVidia 1060 Max-Q) ?
 

Theron Tarigo

Member

Reaction score: 7
Messages: 27

What does glmark2 measure? If it has anything to do with framerate then it won't be useful here. Rendering directly from Intel graphics should have a higher frame throughput than with nvrun-vgl/optirun since needing to transfer frames from Nvidia to Intel over the PCIe bus can become the limiting factor. However in either case it should keep up with your monitor refresh, otherwise there is a real problem.

To reiterate: Optimus GPU performance is expected to be worse than Integrated for simple workloads, but still "fast enough" for display. For complex workloads, Nvidia should outperform the Integrated.
 

Hakaba

Active Member

Reaction score: 121
Messages: 230

Ok, I will find an another benchmark to measure Intel/Nvidia perfs not based on framerate, but on calculation.
I notice no bug with programs lauched via optimus.
 
Top