How to use "prime-select on-demand" in latest Kubuntu 19.10

18,370

Solution 1

This is a confusing new 'option' that isn't described and generally of no use to most users. The bug report that lead to this being added stated -

"Per current NV and intel GPU driver, if we load nvidia.ko only, we can do display on intel GPU and leave the NV to deep learning for a graphic workstation."

Report here - https://bugs.launchpad.net/ubuntu/+source/nvidia-prime/+bug/1824282

Bug filed about how poorly this was implemented here -

https://bugs.launchpad.net/ubuntu/+source/nvidia-settings/+bug/1851416

Solution 2

In ubuntu 19.10 xorg needs some patches that are only available for 18.04 and 19.04 here You can read all information here

first you need to remove intel drivers to use software based rendering (modeseting aka llvmpipe renderer). Install latest drivers from this ppa and finally, compile/install patched xorg.

The easiest solution today is upgrade to ubuntu 20.04 and install nvidia drivers

sudo ubuntu-drivers install

I explicitly configure the iGPU and dGPU devices in xorg.conf.d (BusID could be different in other systems):

$ sudo cat /etc/X11/xorg.conf.d/20-intel.conf 
    Section "Device"
      Identifier  "Intel Graphics"
      Driver      "intel"
      Option      "AccelMethod"    "sna"
    EndSection 

$ sudo cat /etc/X11/xorg.conf.d/90-nvidia.conf 
    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 "dGPU"
      Driver "nvidia"
      BusID          "PCI:3:0:0"  
    EndSection

... reboot and get prime working:

$ offload-glx glxinfo | grep "OpenGL renderer"
OpenGL renderer string: GeForce 940M/PCIe/SSE2

$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: Mesa Intel(R) HD Graphics 5500 (BDW GT2)

offload_glx comes from mate-prime-select and is an alias of this: __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears

So install nvidia drivers, and configure xorg.

Share:
18,370
George
Author by

George

Updated on September 18, 2022

Comments

  • George
    George over 1 year

    I'm using

    Kubuntu 19.10
    Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    NVIDIA UNIX x86_64 Kernel Module  435.21
    

    and since Kubuntu has dropped bumblebee I was looking for another possibility to use nvidia driver per application. Thus, I came to the "PRIME Render Offload" issue, but I do not really understand how it works, even though I've read through NVIDIA Accelerated Linux Graphics Driver README and Installation Guide.

    When I choose prime-select intel I can work exclusively using my intel on-chip graphics, whereas using prime-select nvidia I will be able to use exclusively nvidia GPU, while I have to reboot when selecting respectively. When I choose prime-select on-demand, I can call nvidia-smi, and it will show up as ...

        Wed Nov 13 15:35:06 2019       
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |===============================+======================+======================|
    |   0  GeForce 940MX       Off  | 00000000:02:00.0 Off |                  N/A |
    | N/A   36C    P8    N/A /  N/A |      0MiB /  2004MiB |      0%      Default |
    +-------------------------------+----------------------+----------------------+
    
    +-----------------------------------------------------------------------------+
    | Processes:                                                       GPU Memory |
    |  GPU       PID   Type   Process name                             Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+
    

    but, I cannot verify, if I can really "use" the nvidia GPU, e.g. when calling glxinfo or glxgears I got the info that it does not use nvidia GPU. I also tried what is given in the NVIDIA Readme above, e.g. __NV_PRIME_RENDER_OFFLOAD=1 glxgears, but I cannot prove that the nvidia GPU is used. I fear that the prime-select on-demand option is not really working, or - what is definitely an option - I do not really understand how it works.

    Thus, please, could anyone be so kind to help me here and de-mystify this?

    • RandomGuy
      RandomGuy about 2 years
      Not 100% accurate but may be helpful, you can monitor the memory consumed in NVIDIA-SMI, if it increases when you launch the application, it is likely using the nvidia card. It will also drop the memory used when you quit the application (if it is using the nvidia card).
  • George
    George over 4 years
    Thanks a lot, this explains, that on-demand means "intel+cuda", if I understand well!? However, could you please also give me an indication on how to realize an installation / scenario, which I successfully used for years employing the bumblebee stuff, since I want to avoid rebooting each time I'm using an application which requires "nvidia support/features"?
  • Arg0s
    Arg0s about 4 years
    This is not correct. Yes, anyone with xorg >= 1.20 and nvidia drivers >=435.17 (about august 2019) can do it. Proof of this is the release of PopOS 20.04 (See: "Other Features" section)
  • BeepDog
    BeepDog almost 4 years
    Could you explain that a bit more? I'm on 20.04, and I'm not sure how you "explicitly configure the iGPU and dGPU". Thanks!
  • Celebre Asm
    Celebre Asm almost 4 years
    @BeepDog ok. I edited my answer with my config.