Nvidia Optimus is part ACPI (to provide a way to command GPU to power off), part hardware (to facilitate switching the GPU power on/off while the system is running) and part display drivers (to deal with a GPU that can completely power off and later return in a completely reset state). It is essentially a default feature on all modern dual-GPU systems where the discrete GPU is a Nvidia one.
So you need the X11 graphics to display on the remote box?
In that case, the X11 server on the remote box needs to load both the nvidia
and the i915
drivers, and then perhaps tie them together using xrandr --setprovideroutputsource
options. The DISPLAY
variable should be set to :0
as both GPUs will be treated as parts of a single display.
Unfortunately, there are some limitations and there may be a few more steps to take before you can actually use such a configuration.
First, because of the way the X11 server is designed, it apparently cannot be quite fully "dynamically switched" yet. You must select one of the other GPU as the primary one. Then, the other GPU can be used either as an "output extender" for the primary GPU (providing more display output connectors), or as a "rendering booster processor" for it.
If you're using the non-Nvidia GPU as the primary one (the common configuration on laptops, as the other GPU is usually directly connected to the laptop's integrated display for minimum energy consumption when running on battery), but the xrandr --listproviders
shows the Nvidia GPU as a second provider, then you can just set a pair of environment variables for a program to make it use the Nvidia GPU for rendering its graphics:
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
But if you need to use a display that is physically connected to the Nvidia GPU's output connectors and is not directly accessible by the other GPU, then the Nvidia GPU needs to stay powered up anyway, so you might as well make it the primary one.
If you don't want to do that (e.g. if you want to use the display and the associated GPU only occasionally), then you can tell the Nvidia GPU to receive output from the other GPU with two commands like:
xrandr --setprovideroutputsource NVIDIA-G0 modesetting
xrandr --auto
This is what Nvidia calls "Reverse PRIME", or using the Nvidia GPU as a pass-through for graphics rendered in the other GPU.
However, a full-screen application using the render offload environment variables mentioned earlier will still get rendered natively on Nvidia GPU, skipping the iGPU. This is called "Reverse PRIME Bypass" by Nvidia, and it requires the full-screen application is visible only on a single display connected to the Nvidia GPU.
If you decide to make the Nvidia GPU the primary one, but would still want to use the display outputs of the other GPU, you'll need to set up the link between the GPUs in the other direction:
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
In each case, the xrandr
commands should probably go into your .xinitrc
(if you use startx
) and/or into /etc/X11/Xsession.d/<something>
script (if you use a X Display Manager). The render offload environment variables you can place wherever you want, depending on if you want the render acceleration on all X11 applications you run, or just on some of them.
I don't have access to the newest Ubuntus at the moment, but as I've understood, the prime-select
just provides a few basic configurations: Nvidia GPU only, the other GPU only, and "on-demand" which is essentially a requirement for all I've described above.
Depending on your hardware configuration and the versions of the Nvidia driver and the X server, you might need to add some configuration to /etc/X11/xorg.conf.d/
to allow the X server to start up both drivers even though only one of them has a display attached: for examples, see chapters Offloading Graphics Display with RandR 1.4 and PRIME Render Offload in the README.txt
file of the Nvidia driver. It might be available on your system as /usr/share/doc/NVIDIA_GLX-1.0/README.txt
.
You should probably start by connecting to the remote system, making sure the X11 subsystem is running there, setting DISPLAY=:0
and then running xrandr --listproviders
. If it already lists two providers, then either your driver/X server versions are new enough that both GPUs get auto-detected for dual-GPU use, or Ubuntu has already pre-setup that part for you.
If not, then the first step is to adjust your configuration so that the command will indicate two providers; before that essential step is completed, nothing I described above will work.