PRIME render offloading on Nvidia Optimus

Hello there!

Well, thats a faster reaction then I had expected, but great to hear that it is in the works. Do you have a (very) rough estimate for us how long it is going to be before we can get our hands hands on it?

And I’m also a bit hazy on the details, will this work transparently for applications by just passing DRI_PRIME=1? Just like with open source drivers? And will this work with both OpenGl and Vulkan?

Dox

@aplattner Glad to hear you’re working on it! I’d also like to mention that most major distros are switching to wayland these days, if there is anything like PRIME planned for wayland?

From my (very limited) understanding, a capable compositor can just open any DRM devices (whether found or given otherwise) and use it to render and display, so the whole thing of render-offloading would become a minor problem?

Martin

Hi.

Will this also help this situation too which pretty much plagues every notebook has Intel HD+ GTX 8xx series or newer?

That’s not really one bug but a collection of everything that could go wrong. Some are related to bugs in mutter, some related to nouveau, some to intel…

With Steam Play on Linux, it would be really lovely aswell, if we can run Steam on iGPU, and then when we start a game it can be offloaded to the nvidia gpu. It uses DXVK / vkd3d over Vulkan.

In between games the nvidia gpu could be put in pm-suspend and cooldown / take no battery.

@aplattner Is there a time frame as to when this might get implemented? I would hope it comes out in beta soon as my current implementation is a battery hog

Hello @aplattner, now, with the XDC2018 ending, any news about Kyle, the Savior, and the offloading support on Linux?

As far as I read, NVIDIA(6 years ago when linus literally gave them the middle finger over it) could not support PRIME render offloading because proprietary software could not use DMA_BUF due to licensing constraints. Has either side’s stance changed/will change? I don’t see NVIDIA giving up its proprietary driver(because then people would stop buying overpriced enterprise gpus), neither do I see Linux developers giving up their moral values. What workaround will be used to implement offloading? Because right now there is no good way to do it since nouveau has performance on par with integrated graphics.

I remember that the GPL issues with DMA_BUF were worked around some time ago. Notice though that there are more than “moral values” at play from the kernel developers. The kernel is made from donated code under the GPL from multiple contributors. It is simply not viable to obtain authorization to re-license the code from every single donor . And I am sure nobody is considering violating the terms of the original donations. Some may perceive this as a drawback of the kernel source, but, would there even be a Linux kernel without donated GPL code? Probably not.

I’m glad this is beign worked on. Thank you guys.

I’ve been dealing (giving that term a super-wide berth) for literally over 10 years now under Linux, and my latest (this past weekend) attempts at configuring two GeForce GTX 1080 cards in SLI mode with a hardware bridge that was included with the motherboard I purchased has proven to be the most fruitless struggle of mine to date. I had to go as far as to install Windows 10 on a USB-to-go in order to figure out the correct way to connect my dual-monitor setup into an SLI configuration since each GPU has 3 displayport’s each.

Let me repeat that… I had to install Windows 10 on a USB stick just to figure it out through trial and error using their control panel. Go ahead, find OFFICIAL documentation on the correct way to do it; I dare you. (Spoiler alert: my best educated guess was wrong – according to the control panel both monitors should be plugged into ONE gpu and they should be plugged into the one that is closest to the CPU).

I’m done. I’m so done. I had my hopes crushed once a log time ago when AMD acquired ATI, and since they were so on-point with the open-source community in development of the Athlon processor and toolsets I thought for sure ATI would setup in where NVIDIA dropped the ball countless times on countless occasions it would take 5 lifetimes to compile all the data from forums, blogs, irc logs, etc. Can you believe the experience in using their garbage “proprietary” driver blob was actually worse than dealing with NVIDIA chips?

I suppose the last hope we have is Intel – I heard from a reliable source they are poaching ex and current employees from both ATI and NVIDIA camps in an effort that appears to be for the purpose of throwing their hat in the 3D arena. I hope they do it too. I’ll take an all-in-one bundle that you KNOW will all just work since most likely Intel will fabricate everything themselves – then ATI and NVIDIA won’t have a need to spend all that money on their slick and sexy marketing campaigns for new chipsets that will have more issues with BIOS settings and driver configurations than worth dealing with.

And if Intel doesn’t come through and the third time isn’t the charm? I’ll go back to console mode. I learned Slackware in '96 that way because the only graphics cards that would work in X mostly out of the box were Matrox cards (and sometimes harder-to-find S3 Virge chips). With the way everything is going now in regards to internet content it may be for the better anyway. My Acer Predator laptop with an Intel i7-7700HQ processor and a GeForce GTX 1060 discrete adapter running entirely on a solid-state drive took me over 10 seconds to load the Google Voice webpage with Zoom being the only other application that was running.

I’m done. If Linux finally gets a stable and functional 3D accelerated environment I’ll be happy. If not, I’m going back to text-mode and I’ll still be happy since lynx/links/w3m won’t have to download, process and render megabytes of toolkit/widget bloat the next time Google decides to make their entire platform interface even more of a trashy dumpster-fire than it’s already recently become.

Surely you’re aware that open source AMD drivers pretty much just work now? There were some issues with the recent RX 590 launch, but other than that, you plug the card in and it just works. There’s no need to use the closed source PRO driver anymore for general usage and gaming.

I get the frustration with nvidia’s lack of proper support for Optimus, I really do. Years ago, when I got my thinkpad T430 I kept thinking that soon enough I’d be able to use it under Linux. Last year I ended up replacing the motherboard with one without nvidia, because I’d rather have nothing than deal with this any more. It has become quite obvious that the only viable GPU vendor option for Linux users is AMD, so please stop supporting nvidia’s market domination and start buying hardware from people who actually care.

This week Kyle pushed a new GLX extension to make possible the PRIME offloading. [url]Sign in · GitLab

Do NVidia have any expecting release plan for this support, since everithing in Xorg seems to be implemented now (just waiting feedback/merging)?

This seems like the X server bits @aplattner was referring to

RE: PRIME GPU Offloading Improvement For GLXVND Merged For X.Org Server 1.21
TH;CR ans at bottom
SINCE 2012…

nVIDIA rebuffed by kernel developers in January 2012 2012!!!

An attempt by Nvidia to support Optimus through DMA BUF, a Linux kernel-mechanism for sharing buffers across hardware (potentially GPUs), was rebuffed by kernel developers in January 2012 due to license incompatibility between the GPL-licensed kernel-code and the proprietary-licensed Nvidia blob

Then YESTERDAY:

follow link to:

Request to merge kbrenneman:GLXVND-per-client-vendor into master

Closed by Aaron Plattner 1 day ago
“The changes were not merged into master” again

BUT THEN THIS HAPPENED and a little more if you look…

Add NV24 and NV42 pixel formats
WTF ???

ans:

"avutil: Add NV24 and NV42 pixel formats

These are the 4:4:4 variants of the semi-planar NV12/NV21 formats.

These formats are not used much, so we’ve never had a reason to add
them until now. VDPAU recently added support HEVC 4:4:4 content
and when you use the OpenGL interop, the returned surfaces are in
NV24 format, so we need the pixel format for media players, even
if there’s no direct use within ffmpeg.

Separately, there are apparently webcams that use NV24, but I’ve
never seen one."

Who or what uses that then ?

Unredistributable if compiled with NVIDIA Performance Primitives. Website, ffmpeg.org. FFmpeg is a free and open-source project consisting of a vast software suite of libraries and … as input formats. The command ffmpeg -pix_fmts provides a list of supported pixel formats. … YVU 4:4:4, -, -, (8bpc (YV24)), -, 8bpc (NV42), -.

Unredistributable if compiled with NVIDIA Performance Primitives.

then this…

nVidia Dev DGAF
@: https://gist.github.com/Brainiarc7/5fbecef51470d2d25a0747444abc2c53

/ffmpeg-nvprime-build.md
FFmpeg build for NVIDIA PRIME-enabled systems on Ubuntu 18.04LTS+. NVENC, QuickSync and VAAPI hwaccels are enabled.

Looks like Kyle’s code is now in the master branch. So I guess now we wait for an NVIDIA driver update to take advantage of it?

Good news!

Is there any chance this could get backported to nvidia-390xx?

Just tested this and works flawless so far even with Steam Proton. When nvidia-drm.modeset=1 is set, the nvidia gpu also has to be set up in xorg.conf, otherwise the modesetting driver grabs the nvidia device, e.g.

Section "ServerLayout"
  Identifier "layout"
  Screen 0 "iGPU"
  Option "AllowNVIDIAGPUScreens"
EndSection

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

Section "Screen"
  Identifier "iGPU"
  Device "iGPU"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:7:0:0"
EndSection

Downside of this is that pre-Turing gpus will always stay powered, so the power savings are not that great, at least while idle.
For Turing gpus, the new power management feature was also added.
390 won’t get this, no features will be added to legacy drivers, and telling by the changed driver layout starting with 410 this wasn’t a small change to the driver architecture.

I think a small script that turns on/off the NVidia card with bbswitch and starts the command with prime offloading could be the answer.

bbswitch can only turn off the nvidia gpu when the nvidia driver is unloaded which can’t be done because it’s used by the Xserver.