Edit Info Other
Login

Optimus"

Differences between revisions 14 and 43 (spanning 29 versions)
Revision 14 as of 2017-01-13 12:56:12
Size: 3965
Comment:
Revision 43 as of 2020-06-19 15:16:33
Size: 6834
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from Howto/NVIDIA_Optimus
## page was renamed from Howto/nVidia_Optimus
Line 2: Line 4:
There are additional steps needed to integrate the package with optimus. With Fedora 25 and later, NVIDIA Optimus devices are automatically detected with GDM/Gnome.
They will run with output source and not with offload sync by default.
Line 4: Line 7:
This Howto is a subset of the main documentation, please read the [[Howto/nVidia|Howto NVIDIA]] first. With Fedora 29 , along NVIDIA driver 435.17+ and xorg-x11-server 1.20.5-9 (add additional patches), it's now possible to have full Optimus support (with offload sync only with glx).
Starting with NVIDIA driver 440.26+ render offload works with EGL.
Line 6: Line 10:
Also note that NVIDIA currently only support "outputsource" and not "offloadsink". It means that you cannot disable the dGPU (nvidia).
The current workaround is to reboot onto the free Software version using an alternative grub2 boot menu.

This is only tested using the main driver (367.xx and later).

!!! BIG FAT WARNING - This is still experimental documentation, only experimented users should follow.
I highly recommends to have another PC for remote debug.

== GLVND enabled mesa ==
This is optional for optimus, and will provide a glvnd enabled mesa that will replace the fedora version.
Once installed, it will be easier to switch between FOSS stack (nouveau) and the binary driver (nvidia).
The long term plan is to have the switch enabled in the fedora mesa package (see rhbz#1388810 ).

Note: Copr is not multilibs compliant, you need to copy the x86_64 repo as a new file and replace "arch" to i386, if using 32bit programs.
With Fedora 30 and later, the official fedora xorg-x11-server packages has the needed patches, (so there is no need to use the copr repository).
Using NVIDIA 440.31+ will advertise full optimus support (GL/EGL) using a stable driver release.
It's not needed to use the previous copr repository that can be disabled using:
Line 21: Line 14:
dnf copr enable kwizart/glvnd
dnf update
dnf config-manager --set-disable copr:copr.fedorainfracloud.org:kwizart:xorg-x11-server_nvidia
Line 25: Line 17:
== KMS for nvidia ==
Enable Kernel Mode Setting for nvidia-drm, this is needed for buffer sharing with the intel adapter:
This Howto is a subset of the main documentation, please read the [[Howto/NVIDIA|NVIDIA]] Howto first.


== Known limitation ==
Full Optimus Support can be achieved with xorg-x11-server 1.20.5-9 from official fedora packages (for Fedora 30 and later).
This package has patches backported that have lander in xorg-x11-server master branch (that will become xorg 1.21).


== NVIDIA PRIME Support ==
On Fedora 30 and later, with NVIDIA driver 440.31+, there is nothing else to be done beyound normal driver installation.
But you can opt-in to enable Dynamic Power Management until this is set as the default in the NVIDIA driver.
Line 28: Line 29:
grubby --update-kernel=$(uname -r) --args="nvidia-drm.modeset=1" --remove-args="video=vesa:off" sudo -s
dnf update
cat > /etc/modprobe.d/nvidia.conf <<EOF
# Enable DynamicPwerManagement
# http://download.nvidia.com/XFree86/Linux-x86_64/440.31/README/dynamicpowermanagement.html
options nvidia NVreg_DynamicPowerManagement=0x02
EOF
}}}
Line 30: Line 38:
 [ -f /boot/grub2/grub.cfg ] && grub2-mkconfig -o /boot/grub2/grub.cfg == PRIME Render Offload ==
As documented at http://download.nvidia.com/XFree86/Linux-x86_64/440.31/README/primerenderoffload.html
Line 32: Line 41:
 [ -f /boot/efi/EFI/fedora/grub.cfg ] && grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg === Configure Graphics Applications to Render Using the GPU Screen ===

To configure a graphics application to be offloaded to the NVIDIA GPU screen, set the environment variable __NV_PRIME_RENDER_OFFLOAD to 1. If the graphics application uses Vulkan, that should be all that is needed. If the graphics application uses GLX, then also set the environment variable __GLX_VENDOR_LIBRARY_NAME to nvidia, so that GLVND loads the NVIDIA GLX driver. NVIDIA's EGL implementation does not yet support PRIME render offload.

Examples:
{{{
__NV_PRIME_RENDER_OFFLOAD=1 vkcube
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep vendor
}}}

=== Finer-Grained Control of Vulkan ===

The __NV_PRIME_RENDER_OFFLOAD environment variable causes the special Vulkan layer VK_LAYER_NV_optimus to be loaded. Vulkan applications use the Vulkan API to enumerate the GPUs in the system and select which GPU to use; most Vulkan applications will use the first GPU reported by Vulkan. The VK_LAYER_NV_optimus layer causes the GPUs to be sorted such that the NVIDIA GPUs are enumerated first. For finer-grained control, the VK_LAYER_NV_optimus layer looks at the __VK_LAYER_NV_optimus environment variable. The value NVIDIA_only causes VK_LAYER_NV_optimus to only report NVIDIA GPUs to the Vulkan application. The value non_NVIDIA_only causes VK_LAYER_NV_optimus to only report non-NVIDIA GPUs to the Vulkan application.

Examples:
{{{
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only vkcube
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=non_NVIDIA_only vkcube
}}}

=== Finer-Grained Control of GLX + OpenGL ===

For GLX + OpenGL, the environment variable __NV_PRIME_RENDER_OFFLOAD_PROVIDER provides finer-grained control. While __NV_PRIME_RENDER_OFFLOAD=1 tells GLX to use the first NVIDIA GPU screen, __NV_PRIME_RENDER_OFFLOAD_PROVIDER can use an RandR provider name to pick a specific NVIDIA GPU screen, using the NVIDIA GPU screen names reported by `xrandr --listproviders`.

Examples:
{{{
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears
__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears
}}}

== External Monitors detection ==

At this time, external monitors connected to the NVIDIA GPU requires the PrimaryGPU option to be set.
See the next topic about how to setup as appropriate.

== NVIDIA PrimaryGPU Support ==
Using PrimaryGPU allows to use the NVIDIA driver by default instead of the iGPU. This is also required in order to use external display when internally connected from the NVIDIA hardware. Unfortunately, setting this option automatically when an external display is connected is not supported by NVIDIA at this time.
To recover this previous behaviour, you can use:
{{{
cp -p /usr/share/X11/xorg.conf.d/nvidia.conf /etc/X11/xorg.conf.d/nvidia.conf
}}}

And edit the file to use: Option "PrimaryGPU" "yes"

/!\ SSDM and lightdm display manager users: Please Have a look at the [[https://wiki.archlinux.org/index.php/NVIDIA_Optimus#Display_managers|ArchLinux wiki about configuring display manager]]. In Fedora, Gnome users don't need this change.


== PRIME Synchronization ==
With Xorg server 1.19 (Fedora 25 and later), this feature allows buffer sharing between the Intel and the NVIDIA card when using Xorg (not relevant for Wayland).
It should be enabled bytThen you can enable Prime Synchronisation for your session:
{{{
xrandr --output <output> --set "PRIME Synchronization" 1
Line 36: Line 96:
== Additional Configuration ==
 * For Fedora 25 and later. Please verify to have the modified xorg-x11-server package currently in updates-testing repository. It contains some not yet upstream [[https://lists.x.org/archives/xorg-devel/2016-December/052066.html|patches]] by Hans De Goede (Fedora/RPM Fusion contributor).
{{{
dnf update xorg-x11-server\* --enablerepo=updates-testing
rpm -q xorg-x11-server-Xorg
xorg-x11-server-Xorg-1.19.0-3.fc25
}}}
== Proprietary/FLOSS switch ==
At this time, this can be done by manually editing "rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1" from the grub2 cmdline. And replace by "rd.driver.blacklist=nvidia,nvidia_drm,nvidia_modeset modprobe.blacklist=nvidia,nvidia_drm,nvidia_modeset"
The plan is to have a grub2 menu to have the choice. Please see [[https://bugzilla.rpmfusion.org/show_bug.cgi?id=4315|Bugzilla [RFE] Switcher for Xorg nvidia/FOSS config]]
Line 44: Line 100:
 * Up to Fedora 24 , you still need a xorg.conf and adapted display manager configuration (GDM, KDM, LightDM, etc).

'''Please verify to Update the BusID earch GPU, specially for the nvidia device.'''
{{{
cat>/etc/X11/xorg.conf<<EOF
# RPM Fusion - nvidia-xorg.conf
#

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

Section "Device"
    Identifier "intel"
    Driver "modesetting"
    # Change BusID if necessary. Tips: (lspci | grep VGA) (Change 00:02.0 to 0:2:0)
    BusID "PCI:0:2:0"
    Option "AccelMethod" "none"
EndSection

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

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    # Change BusID if necessary. Tips: (lspci | grep 3D) (Change 01:00.0 to 1:0:0)
    BusID "PCI:1:0:0"
    Option "AllowEmptyInitialConfiguration"
EndSection

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


cat>/etc/X11/xinit/xinitrc.d/05-nvidia.sh<<EOF
#!/bin/bash

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

EOF
chmod +x /etc/X11/xinit/xinitrc.d/05-nvidia.sh

}}}

Others Display Manager tweaks, needed for GDM, KDM, LightDM, etc:

https://wiki.archlinux.org/index.php/NVIDIA_Optimus#Display_Managers
Line 103: Line 103:
 *A: nvidia-prime is not something from NVIDIA despite the name. It's a collection of integration scripts made by canonical for Ubuntu. Best would be to avoid using custom scripts and to have the driver to setup appropriately if on Optimus hardware or single GPU setup.  *A: nvidia-prime is not something from NVIDIA despite the name. It's a collection of integration scripts made by canonical for Ubuntu. Better to avoid using custom scripts and to have the driver to setup appropriately if on Optimus hardware or single GPU setup. With Fedora 25 and later, everything is automatically setup.
Line 106: Line 106:
 * http://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/primerenderoffload.html
 * http://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/dynamicpowermanagement.html
Line 108: Line 110:

----
CategoryHowto

Introduction

With Fedora 25 and later, NVIDIA Optimus devices are automatically detected with GDM/Gnome. They will run with output source and not with offload sync by default.

With Fedora 29 , along NVIDIA driver 435.17+ and xorg-x11-server 1.20.5-9 (add additional patches), it's now possible to have full Optimus support (with offload sync only with glx). Starting with NVIDIA driver 440.26+ render offload works with EGL.

With Fedora 30 and later, the official fedora xorg-x11-server packages has the needed patches, (so there is no need to use the copr repository). Using NVIDIA 440.31+ will advertise full optimus support (GL/EGL) using a stable driver release. It's not needed to use the previous copr repository that can be disabled using:

dnf config-manager --set-disable copr:copr.fedorainfracloud.org:kwizart:xorg-x11-server_nvidia 

This Howto is a subset of the main documentation, please read the NVIDIA Howto first.

Known limitation

Full Optimus Support can be achieved with xorg-x11-server 1.20.5-9 from official fedora packages (for Fedora 30 and later). This package has patches backported that have lander in xorg-x11-server master branch (that will become xorg 1.21).

NVIDIA PRIME Support

On Fedora 30 and later, with NVIDIA driver 440.31+, there is nothing else to be done beyound normal driver installation. But you can opt-in to enable Dynamic Power Management until this is set as the default in the NVIDIA driver.

sudo -s
dnf update
cat > /etc/modprobe.d/nvidia.conf <<EOF
# Enable DynamicPwerManagement
# http://download.nvidia.com/XFree86/Linux-x86_64/440.31/README/dynamicpowermanagement.html
options nvidia NVreg_DynamicPowerManagement=0x02
EOF

PRIME Render Offload

As documented at http://download.nvidia.com/XFree86/Linux-x86_64/440.31/README/primerenderoffload.html

Configure Graphics Applications to Render Using the GPU Screen

To configure a graphics application to be offloaded to the NVIDIA GPU screen, set the environment variable NV_PRIME_RENDER_OFFLOAD to 1. If the graphics application uses Vulkan, that should be all that is needed. If the graphics application uses GLX, then also set the environment variable GLX_VENDOR_LIBRARY_NAME to nvidia, so that GLVND loads the NVIDIA GLX driver. NVIDIA's EGL implementation does not yet support PRIME render offload.

Examples:

__NV_PRIME_RENDER_OFFLOAD=1 vkcube
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep vendor

Finer-Grained Control of Vulkan

The NV_PRIME_RENDER_OFFLOAD environment variable causes the special Vulkan layer VK_LAYER_NV_optimus to be loaded. Vulkan applications use the Vulkan API to enumerate the GPUs in the system and select which GPU to use; most Vulkan applications will use the first GPU reported by Vulkan. The VK_LAYER_NV_optimus layer causes the GPUs to be sorted such that the NVIDIA GPUs are enumerated first. For finer-grained control, the VK_LAYER_NV_optimus layer looks at the VK_LAYER_NV_optimus environment variable. The value NVIDIA_only causes VK_LAYER_NV_optimus to only report NVIDIA GPUs to the Vulkan application. The value non_NVIDIA_only causes VK_LAYER_NV_optimus to only report non-NVIDIA GPUs to the Vulkan application.

Examples:

__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only vkcube
__NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=non_NVIDIA_only vkcube

Finer-Grained Control of GLX + OpenGL

For GLX + OpenGL, the environment variable NV_PRIME_RENDER_OFFLOAD_PROVIDER provides finer-grained control. While NV_PRIME_RENDER_OFFLOAD=1 tells GLX to use the first NVIDIA GPU screen, NV_PRIME_RENDER_OFFLOAD_PROVIDER can use an RandR provider name to pick a specific NVIDIA GPU screen, using the NVIDIA GPU screen names reported by xrandr --listproviders.

Examples:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears
__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 __GLX_VENDOR_LIBRARY_NAME=nvidia glxgears

External Monitors detection

At this time, external monitors connected to the NVIDIA GPU requires the PrimaryGPU option to be set. See the next topic about how to setup as appropriate.

NVIDIA PrimaryGPU Support

Using PrimaryGPU allows to use the NVIDIA driver by default instead of the iGPU. This is also required in order to use external display when internally connected from the NVIDIA hardware. Unfortunately, setting this option automatically when an external display is connected is not supported by NVIDIA at this time. To recover this previous behaviour, you can use:

cp -p /usr/share/X11/xorg.conf.d/nvidia.conf /etc/X11/xorg.conf.d/nvidia.conf

And edit the file to use: Option "PrimaryGPU" "yes"

/!\ SSDM and lightdm display manager users: Please Have a look at the ArchLinux wiki about configuring display manager. In Fedora, Gnome users don't need this change.

PRIME Synchronization

With Xorg server 1.19 (Fedora 25 and later), this feature allows buffer sharing between the Intel and the NVIDIA card when using Xorg (not relevant for Wayland). It should be enabled bytThen you can enable Prime Synchronisation for your session:

xrandr --output <output> --set "PRIME Synchronization" 1

Proprietary/FLOSS switch

At this time, this can be done by manually editing "rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1" from the grub2 cmdline. And replace by "rd.driver.blacklist=nvidia,nvidia_drm,nvidia_modeset modprobe.blacklist=nvidia,nvidia_drm,nvidia_modeset" The plan is to have a grub2 menu to have the choice. Please see Bugzilla [RFE] Switcher for Xorg nvidia/FOSS config

FAQ

  • Q: Why there is no nvidia-prime package ?
  • A: nvidia-prime is not something from NVIDIA despite the name. It's a collection of integration scripts made by canonical for Ubuntu. Better to avoid using custom scripts and to have the driver to setup appropriately if on Optimus hardware or single GPU setup. With Fedora 25 and later, everything is automatically setup.

References


CategoryHowto

Howto/Optimus (last edited 2020-06-19 15:16:33 by NicolasChauvet)