Edit Info Other
Create account
Login

Optimus"

Differences between revisions 29 and 32 (spanning 3 versions)
Revision 29 as of 2018-09-01 19:16:37
Size: 2499
Comment:
Revision 32 as of 2019-08-20 17:39:05
Size: 5643
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
With Fedora 25 and later, NVIDIA Optimus devices are automatically detected. 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 NVIDIA driver 435.17 and xorg-x11-server 1.20 (with additional patches), it's now possible to have full Optimus support on Fedora 29 and later.
Line 10: Line 14:
Please 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 boot option menu.
Full Optimus Support can be achieved with xorg-x11-server 1.20.5 with patches as provided in a COPR repository.
For information, the support as landed officially in Xorg server 1.21 that might be provided by default for Fedora 32.
I Highly recommends Optimus users to enable this COPR repository to benefit from Full Optimus Support ahead of Xorg 1.21.


== NVIDIA PRIME Support ==
{{{
sudo -s
dnf copr enable kwizart/xorg-x11-server_nvidia
dnf update xorg-x11-server\*
dnf update --enablerepo=rpmfusion-nonfree-rawhide xorg-x11-drv-nvidia\*
cat > /etc/modprobe.d/nvidia.conf <<EOF
# Enable DynamicPwerManagement
# http://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/dynamicpowermanagement.html
options nvidia NVreg_DynamicPowerManagement=0x02
EOF
}}}

== PRIME Render Offload ==
As documented at http://download.nvidia.com/XFree86/Linux-x86_64/435.17/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


== NVIDIA PrimaryGPU Support ==
Before the Full optimus support, the only way to enable the NVIDIA driver was to set the NVIDIA GPU to be used by default.
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"
Line 16: Line 75:

Verify to have nvidia-drm-modeset=1 enabled looking in /proc/cmdline.
If not enabled, you can run:
{{{
sudo grubby --update-kernel=ALL --args="nvidia-drm.modeset=1"
}}}

You need to reboot to enable nvidia-drm modesetting.
Then you can enable Prime Synchronisation for your session:
It should be enabled bytThen you can enable Prime Synchronisation for your session:
Line 29: Line 80:
If everything works as appropriate, you should consider to edit /etc/default/grub and add the ''nvidia-drm.modeset=1'' option to the GRUB_CMDLINE_LINUX_DEFAULT variable.
If something didn't get right. You can recover using ''e'' from the grub2 edit menu at boot time and manually remove that option. Then on the next boot, use:
{{{
sudo grubby --update-kernel=ALL --remove-args="nvidia-drm.modeset=1"
}}}

Line 38: Line 82:
At this time, this can be done by manually removing "rd.driver.blacklist=nouveau modprobe.blacklist=nouveau" from the grub2 cmdline. 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"
Line 47: Line 91:
 * 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

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 NVIDIA driver 435.17 and xorg-x11-server 1.20 (with additional patches), it's now possible to have full Optimus support on Fedora 29 and later.

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 with patches as provided in a COPR repository. For information, the support as landed officially in Xorg server 1.21 that might be provided by default for Fedora 32. I Highly recommends Optimus users to enable this COPR repository to benefit from Full Optimus Support ahead of Xorg 1.21.

NVIDIA PRIME Support

sudo -s
dnf copr enable kwizart/xorg-x11-server_nvidia
dnf update xorg-x11-server\*
dnf update --enablerepo=rpmfusion-nonfree-rawhide xorg-x11-drv-nvidia\*
cat > /etc/modprobe.d/nvidia.conf <<EOF
# Enable DynamicPwerManagement
# http://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/dynamicpowermanagement.html
options nvidia NVreg_DynamicPowerManagement=0x02
EOF

PRIME Render Offload

As documented at http://download.nvidia.com/XFree86/Linux-x86_64/435.17/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

NVIDIA PrimaryGPU Support

Before the Full optimus support, the only way to enable the NVIDIA driver was to set the NVIDIA GPU to be used by default. 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"

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

Howto/Optimus (last edited 2019-10-18 13:41:24 by NicolasChauvet)