NVIDIA PRIME configuration problem on desktop PC (not laptop, not notebook), can't enable Intel graphics

Hello everyone,

I try to use NVIDIA PRIME on my desktop PC (Intel Core i7 6700K Intel HD 520 + Nvidia GTX 970, motherboard ASUS Z170 Pro Gaming). Manjaro KDE 20.1 fresh installation.

First of all, both graphics cards are enabled:

$ inxi -GMCS
System:
  Host: manjaro Kernel: 5.8.6-1-MANJARO x86_64 bits: 64 
  Desktop: KDE Plasma 5.19.5 Distro: Manjaro Linux 
Machine:
  Type: Desktop Mobo: ASUSTeK model: Z170 PRO GAMING v: Rev X.0x 
  serial: <superuser/root required> UEFI: American Megatrends v: 3805 
  date: 05/16/2018 
CPU:
  Topology: Quad Core model: Intel Core i7-6700K bits: 64 type: MT MCP 
  L2 cache: 8192 KiB 
  Speed: 800 MHz min/max: 800/4200 MHz Core speeds (MHz): 1: 800 2: 800 3: 800 
  4: 800 5: 800 6: 800 7: 800 8: 800 
Graphics:
  Device-1: Intel HD Graphics 530 driver: i915 v: kernel 
  Device-2: NVIDIA GM204 [GeForce GTX 970] driver: nvidia v: 450.66 
  Display: x11 server: X.Org 1.20.8 driver: modesetting,nvidia resolution: 
  1: 1280x1024~75Hz 2: 1920x1080~60Hz 
  OpenGL: renderer: GeForce GTX 970/PCIe/SSE2 v: 4.6.0 NVIDIA 450.66

I installed drivers using mhwd:

$ sudo mhwd -l

0000:01:00.0 (0300:10de:13c2) Display controller nVidia Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
    video-nvidia-450xx            2019.10.25               false            PCI
    video-nvidia-440xx            2019.10.25               false            PCI
    video-nvidia-435xx            2019.10.25               false            PCI
    video-nvidia-430xx            2019.10.25               false            PCI
    video-nvidia-418xx            2019.10.25               false            PCI
    video-nvidia-390xx            2019.10.25               false            PCI
           video-linux            2018.05.04                true            PCI
     video-modesetting            2020.01.13                true            PCI
            video-vesa            2017.03.12                true            PCI


0000:00:02.0 (0380:8086:1912) Display controller Intel Corporation:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
           video-linux            2018.05.04                true            PCI

$ sudo mhwd -i pci video-hybrid-intel-nvidia-450xx-prime

As you can see, video-hybrid-intel-nvidia-450xx-prime is not available when listing configurations.
My problem now is that my system is only using Nvidia graphics card, instead of PRIME offloading:

$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: GeForce GTX 970/PCIe/SSE2
$ prime-run glxinfo | grep "OpenGL renderer"              
OpenGL renderer string: GeForce GTX 970/PCIe/SSE2

$ nvidia-smi
Mon Sep 21 09:20:26 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.66       Driver Version: 450.66       CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 970     Off  | 00000000:01:00.0  On |                  N/A |
|  0%   44C    P0    46W / 200W |    381MiB /  4034MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A       767      G   /usr/lib/Xorg                     133MiB |
|    0   N/A  N/A      1010      G   /usr/bin/kwin_x11                  41MiB |
|    0   N/A  N/A      1061      G   /usr/bin/plasmashell               41MiB |
|    0   N/A  N/A      1285      G   ...AAAAAAAAA= --shared-files      156MiB |
+-----------------------------------------------------------------------------+

As you can see, in both cases, the renderer string shows Nvidia.
My question is, is it possible to configure my desktop to use PRIME offload? If so, how?
Thanks in advice.

I’m pretty sure, yes, but if want to use display outputs of the nvidia gpu, then I do not recommend it. Get rid of the mhwd created Xorg configuration, and try what’s here.

My mhwd-created xorg files are empty.
Why you do not recommend it? My goal is to have working video hardware acceleration in chromium, but I can’t make it work with NVIDIA drivers on…

See here.

The main issues I have, and seemingly many others is:

  • in reverse-prime mode the external + internal screens are treated as one large virtual screen with the smaller screen showing only a portion of the virtual screen.
  • laggy external display
  • above a certain res threshold the ext-display looks like a scrambled CRT (v-sync invalid on CRT style).

and

No change with 450.57

  • External as single display is extremely laggy
  • Same virtual desktop issue as above post with photos
  • Virtual desktop means that tiling windows left/right spans both screens
  • Native res on external of 3440x1440 is warped like a CRT with incorrect v-sync

I tested it, and can confirm that these are true.

What do you have installed?

mhwd -li

But most likely one way or the other you can just install with:

sudo mhwd -f -i pci video-hybrid-intel-nvidia-450xx-prime

@pobrn … I am not sure OP actually wants reverse-prime … I think they just want ‘prime’ to be installed at all. Their current ‘problem’ is that the prime profile is not offered and currently both ‘modesetting’ and ‘nvidia’ are in use in tandem.
Obliterating mhwd/xorg and manually creating files outside of the package manager, etc etc … is probably not required (or advisable).

If the Xorg server runs on the nvidia gpu (which is the case here), then PRIME render offload doesn’t really make any sense (in this case, at least). In my interpretation s/he want’s to run the Xorg server on the intel gpu to be able to to use VA-API hardware acceleration in Chromium, and render games/etc. on the the nvidia gpu with GPU with PRIME render offload.

In that case, if s/he wants to use the display outputs of the nvidia gpu, then “reverse PRIME” (nvidia gpu as output sink) is needed.

If reverse-prime is desired then yes it would technically be something ‘outside’ of mhwd.

It would go a bit like this:
https://wiki.archlinux.org/index.php/PRIME#Reverse_PRIME

(though I would still probably start by using the mhwd PRIME profile …)

Yes, I (he) want to run X11 on Intel GPU, but I want to have possibility to use Nvidia graphics with Steam or with virtual machine - so as I understand I need PRIME, not Reverse PRIME. I have installed properly hybrid drivers, but X11 still uses NVIDIA instead of Mesa

$ mhwd -li
> Installed PCI configs:
--------------------------------------------------------------------------------
                  NAME               VERSION          FREEDRIVER           TYPE
--------------------------------------------------------------------------------
video-hybrid-intel-nvidia-450xx-prime            2019.10.25               false            PCI
     video-modesetting            2020.01.13                true            PCI


Warning: No installed USB configs!

I use PRIME on my laptop and it’s working fine. I want the same thing on my desktop PC.

Try to use the nvidia recommended configuration.

And there is a very important question: do you want to use the display outputs of the nvidia gpu?

I’m sorry but I do not understand. What is Nvidia recommended configuration?
Yes, I want to use outputs from Nvidia GPU

This is it.

In that case you’ll need “reverse PRIME”. As I’ve explained to someone else, “reverse PRIME” is an inadequate name in my opinion. Furthermore, reverse PRIME and PRIME render offload are not mutually exclusive.

If you want intel by default, and nvidia when you need it … thats ‘regular’ prime.
With the above profile (video-hybrid-intel-nvidia-450xx-prime) … it should work like:

glxinfo | grep renderer
prime-run glxinfo | grep renderer

(again though … maybe we are misunderstanding…)

Cool, I thought these are mutually exclusive. The name suggests that.

Can you help me with xorg.conf file?

$ sudo nvidia-xconfig --prime

WARNING: Unable to locate/open X configuration file.

X Configuration file set up for PRIME. Please run "xrandr --setprovideroutputsource
modesetting NVIDIA-0" and "xrandr --auto" to enable. See the README for more details.
Option "AllowEmptyInitialConfiguration" "True" added to Screen "Screen0".
New X configuration file written to '/etc/X11/xorg.conf'
$ cat /etc/X11/xorg.conf
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 450.66

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    Inactive       "InactiveDevice1"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
EndSection

Section "Device"
    Identifier     "InactiveDevice1"
    Driver         "modesetting"
    VendorName     "Unknown"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

But it does not work. Nvidia GPU is used anyways. I want to use Intel GPU for X11 by default, and Nvidia GPU only with prime-run.

Yeah… because those are inadequate names.

The config you just generated is actually the opposite of what you want. You want the config I linked. Please backup 90-mhwd.conf and delete it from /etc/X11/xorg.conf.d/, also delete /etc/X11/xorg.conf.

And when you try it, make sure to connect a display to an output of the intel gpu.

$ cat /etc/X11/xorg.conf.d/90-mhwd.conf
##
## Generated by mhwd - Manjaro Hardware Detection
##

It’s empty as I said. On my laptop it’s also empty, but it’s working fine. On my laptop Intel GPU is used for X11, Nvidia only with prime-run.

Then you can just leave it as it is. But delete xorg.conf.

I’m reading once again all posts. This is exactly what I want, but I do not know what to do right now… I do not understand structure of xorg files, what are screens and monitors. Do I need to give BusID for GPUs? If not, how xorg determines which GPU is which one. I’m very confused…

Delete the xorg.conf file. Then create /etc/X11/xorg.conf.d/10-nvopsink.conf with the following content:

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Inactive "nvidia"
    Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
EndSection

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    BusID "<BusID for Intel device here>"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Of course, fill in the bus id for the intel device. Run lspci | grep -i "vga.*intel" | cut -d ' ' -f 1, if the output is, for example, 00:02.0, then you’ll need to write

BusID "PCI:0:2:0"

in the configuration file.

For some reason, my lspci returns Display not VGA compatible controller for Intel GPU.

$ lspci | grep -e VGA -e Display
00:02.0 Display controller: Intel Corporation HD Graphics 530 (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204 [GeForce GTX 970] (rev a1)

I did exactly what you said:

$ cat /etc/X11/xorg.conf.d/10-nvopsink.conf
Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Inactive "nvidia"
    Option "AllowNVIDIAGPUScreens"
EndSection

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

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
EndSection

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

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection
$  glxinfo | grep "OpenGL renderer"
OpenGL renderer string: GeForce GTX 970/PCIe/SSE2
$ prime-run glxinfo | grep "OpenGL renderer"
OpenGL renderer string: GeForce GTX 970/PCIe/SSE2

Is there any other Xorg configuration? Either /etc/X11/xorg.conf or in /etc/X11/xorg.conf.d/?