For Linux users with NVIDIA/Intel hybrid graphics laptops, having everything working perfectly or at least to the extent that their needs are met from the computer sometimes requires intervention by the user if the chosen distribution does not set it up. Sometimes this includes adjusting the system configuration to prevent the FLOSS Nouveau driver from being loaded or installing card switching technology such as Bumblebee. The last of these is what I have always done on the Dell G5, and sometimes on my older Acer -- at least when I first got it.
Because of unfortunate port physical internal wiring choices by Dell on my G5, I've had to stop using Bumblebee and find other solutions for the distributions I have installed on the G5. This article discusses the problems and the solutions.
Update 20 July 2023:
The discussion in this article focuses on Optimus with NVIDIA GPUs prior to the Turing architecture generation. Newer NVIDIA GPUs incorporate Runtime D3 Power Management capabilities which allow the NVIDIA driver to manage the power state, but only in hybrid graphics mode. As a consequence the integrated only graphics mode is not available and Optimus management tools can not be used to switch to this mode. Also external tools such as bbswitch can not be used to manage the power state of these new GPUs. For a discussion appropriate to these newer cards, including the context for what is meant by Runtime D3 Power Management, see the more recent article Nvidia Optimus on Linux.
This article was motivated by my recent purchase of an LG 43" 4K TV to use as an external monitor with my two main laptops a Dell G5 with Optimus hybrid graphics consisting an integrated Intel UHD630 and a discrete NVIDIA GTX-1050 Ti Mobile, and an older Acer V15 Nitro with an integrated Intel HD530 and a discrete NVIDIA GTX-960 M. The Dell has always been problematic with Nouveau drivers, and I recently found that the HDMI port on the Dell is internally wired to the NVIDIA card, requiring a change in how I've typically solved the Nouveau issue in order to be able to use an external monitor with the laptop.
Many distributions use the FLOSS Nouveau driver by default on their installation medium live environments and install Nouveau by default in the installed system. Manjaro is an exception that gives users a choice during the boot of the installation medium, and Arch, of course, also forces users to choose everything including graphics drivers.
In the distributions that use Nouveau by default, the experience ranges from unusable -- with a black screen -- to erratic behavior of application windows and mouse/touchpad pointer. Those who have read the reviews on this site over the course of the past year are familiar with these problems. The solution I have used has been to start the live environment and the first boot of the installed system with appropriate kernel options to prevent the loading of the Nouveau driver kernel module and then install proprietary NVIDIA drivers and Bumblebee.
The default Bumblebee configuration was a good solution because its default configuration loads the Intel driver at system startup and prevents the NVIDIA driver from being loaded. It also uses bbswitch to keep the NVIDIA card off to preserve battery life. It does, however, allow using the NVIDIA card on demand on an application-by-application basis. I didn't use this feature but I was able to use the laptop without any problems for my needs which doesn't require gaming and didn't require the use of the HDMI port.
I should note that Fedora 32 KDE Spin is the first distribution that I have used where the default Nouveau setup works without any problems. This could be a result of, as stated by the Fedora project leader, Fedora's commitment to provide at least complete basic functionality, if not the high performance of proprietary drivers, with only FLOSS products. For details on the Fedora 32 KDE Spin experience see Fedora 32 Review [KDE Spin]
The Bumblebee based solution worked well for my use case until I wanted to use an external monitor connected to the HDMI port. As I mentioned above, it turns out that the HDMI port, and presumably the USB-C/Thunderbolt 3 port, which can be used as a Display Port with an adapter, is internally wired to the NVIDIA card. This means that Bumblebee can't be used without a lot of manual configuration of X, kernel modules, and related items. The reason that precludes Bumblebee from being used easily is that in its default state, without the configuration modifications mentioned on one of the Bumblebee project GitHub pages is that only the Intel card is powered and only its kernel modules are loaded by default and the NVIDIA card is powered off and its modules are not loaded. This is a problem because, due to the nature of the internal wiring in this laptop, the NVIDIA card must be powered on and the kernel modules must be loaded for the HDMI port to be active and available when an external monitor is plugged in.
So the solution that I sought was to install both Intel and NVIDIA drivers and switch between them as necessary, using the Intel card by default and switching to the NVIDIA card if I am plugged in and want to take advantage of the NVIDIA card for its performance and its 4 GB of video memory, and more importantly, want to use the external monitor.
The extent to which the various distributions that are currently installed on the Dell G5 make this possible is described below.
This was the first distribution in which I was able to solve the problems due to the wiring of the HDMI port, thanks to the documentation which clearly stated the possible solutions for NVIDIA hybrid graphics and the active community which provides solutions. After removing Bumblebee I installed one of the solutions suggested by the Arch wiki -- using optimus-manager, a tool provided by a community member on the Arch User Repository.
The output of
optimus-manager --help
is shown below.
16:26:15 ⌁ [brook@G5-ARCH:~] $ optimus-manager --help usage: optimus-manager [-h] [-v] [--status] [--print-mode] [--print-next-mode] [--print-startup] [--switch MODE] [--set-startup STARTUP_MODE] [--temp-config PATH] [--unset-temp-config] [--no-confirm] [--cleanup] Client program for the Optimus Manager tool. https://github.com/Askannz/optimus-manager optional arguments: -h, --help show this help message and exit -v, --version Print version and exit. --status Print current status of optimus-manager --print-mode Print the GPU mode that your current desktop session is running on. --print-next-mode Print the GPU mode that will be used the next time you log into your session. --print-startup Print the GPU mode that will be used on startup. --switch MODE Set the GPU mode to MODE. You need to log out then log in to apply the change.Possible modes : intel, nvidia, hybrid, auto (auto- detects the mode you may want to switch to). --set-startup STARTUP_MODE Set the startup mode to STARTUP_MODE. Possible modes : intel, nvidia, hybrid --temp-config PATH Set a path to a temporary configuration file to use for the next reboot ONLY. Useful for testing power switching configurations without ending up with an unbootable setup. --unset-temp-config Undo --temp-config (unset temp config path) --no-confirm Do not ask for confirmation and skip all warnings when switching GPUs. --cleanup Remove auto-generated configuration files left over by the daemon.
optimus-manager makes it possible to set, through a command line interface, a default graphics card to be used, the graphics card to use on the next boot, to switch the active graphics card to the other one, or to set a hybrid mode. One of the great and unique features of this tool is that it provides options as to how the power management of the NVIDIA card is to be performed. This is especially fortunate as the the default method provided directly by the NVIDIA driver for power management is only available on the most recent series of NVIDIA graphics cards. The power management options for the older NVIDIA card on the Dell G5 are PCI power control using Nouveau or the kernel itself, bbswitch, and acpi_call. I opted to use the PCI control method using the kernel, where the kernel manages the power through its interface to the PCI.
A companion solution called optimus-manager-qt, also available through the AUR, provides a GUI for managing the configuration of optimus-manager and a panel applet that indicates the current card and provides a right-click menu to switch mode and access settings.
The only drawback is that switching requires logging out interrupting work in progress.
After Arch, Kubuntu 20.04 required the least amount of work to configure the switching between NVIDIA and Intel cards. I specifically wanted to try Kubuntu to see if something similar to the NVIDIA PRIME applet that is available in Ubuntu and Ubuntu MATE made its way to Kubuntu. A similar applet is not available as far as I can tell, but the NVIDIA X Server Settings utility itself offers the switching functionality. This capability of NVIDIA X Server Settings seems to be something added by Ubuntu, as I have not seen this in the NVIDIA X Server Settings program on Arch, openSUSE, or Solus.
Getting to this solution did have some stumbling blocks. First, when using the live environment, I ran into the case where on one occasion I got a black screen and on another I got an unresponsive system during the Plasma splash screen. I made some adjustments to the kernel options in GRUB to get it to start. Second, after installation there were some problems with installing the proprietary NVIDIA drivers, which apparently were not installed. I installed the Additional Drivers package from Discover but after installation it would not start. I then installed the Software and Sources program found in stock Ubuntu. This showed that the proprietary drivers were in use, but if memory servers, I wasn't getting the functionality that I needed.
Finally I installed nvidia-driver-440 in a terminal. This installed dependencies including nvidia-prime and nvidia-settings, after which everything was functional. I could switch between using the Intel card and the NVIDIA card through the PRIME Profiles page of Nvidia X Server Settings, shown in the following set of screenshots.
As I mentioned earlier, this is the only distribution where Nouveau fully works. Not only that, there was no manual intervention of any kind required. I was even able to use the external monitor in the the live environment of the installation medium. Everything including the HDMI port is functional and users don't even have to bother switching cards and then logging out or restarting the machine to effect the switch. The lack of switching, which I haven't investigated because there are no problems, doesn't even affect battery life negatively.
Manjaro, being an Arch based distribution that supports the AUR, can use the same optimus-manager tool to switch between cards, and optionally the same companion program to provide the panel applet. Manjaro, making an Arch system easy for users, also provides optimus-manager directly from its repository, but it should be noted that this version is older than the one available from the AUR.
But because Manjaro's Manjaro Hardware Detection Tool and driver utility does some extra configuration of X, all of the configuration files created by its tools in /etc/X11/xorg.conf.d and the file /etc/X11/xorg.conf, if it exists must be deleted.
Solus's claims of being desktop (as opposed to server) oriented only applies, apparently, to simple hardware configurations. The distribution itself doesn't supply anything like optimus-manager or PRIME Profiles. There is, however, a tool similar to optimus-manager called nvidia-optimus-manager developed by a Solus user for the Solus editions that use LightDM as the display manager. I tried this on Plasma after switching the display manager to LightDM from SDDM, the default used by KDE -- unfortunately losing Plasma greeter capabilities like media control -- with somewhat good results. The following three blocks show its usage.
brook@g5-solus ~ $ sudo nvidia-optimus-manager Password: Usage: /usr/bin/nvidia-optimus-manager status /usr/bin/nvidia-optimus-manager configure nvidia|hybrid|intel /usr/bin/nvidia-optimus-manager autoconfigure
brook@g5-solus ~ $ sudo nvidia-optimus-manager status Current profile: intel OpenGL vendor: Intel Discrete graphics card power status: suspended
brook@g5-solus ~ $ sudo nvidia-optimus-manager configure nvidia Info: selecting the nvidia profile Log out to take effect brook@g5-solus ~ $
While the solutions provided by optimus-manager for Arch and Manjaro and PRIME Profiles functionality added to NVIDIA X Server Settings by Ubuntu for its flavors including Kubuntu worked flawlessly, this tool for Solus did not set the DPI appropriately. This can most likely be corrected by adding an option in the X configuration that is active when the NVIDIA card is being used. As I use Solus less than the other distributions, I haven't tried this but it may be something I might try in the future.
But as a simple workaround for now, it is possible to use Plasma System Settings' Fonts module to force a DPI setting of 96 which solves the problem. Compare the fonts in the terminal window between the screenshot above and the one below. (In the screenshots with improved font display I didn't restart KWin, so fonts in titlebars are still too small. Restarting KWin should solve this.)
openSUSE provides the package suse-prime and another version with bbswitch support for older cards that are not capable of NVIDIA's own power management. The help output from the program is below.
15:22:32 [brook@G5-openSUSE:~] $ sudo prime-select --help NVIDIA/Intel video card selection for NVIDIA Optimus laptops. usage: prime-select nvidia|intel|intel2|unset|get-current|get-boot|log-view|log-clean usage: prime-select boot nvidia|intel|intel2|last usage: prime-select next-boot nvidia|intel|intel2|abort usage: prime-select service check|disable|restore nvidia: use the NVIDIA proprietary driver intel: use the Intel card with the "modesetting" driver PRIME Render Offload possible with >= 435.xx NVIDIA driver with prime-select service DISABLED intel2: use the Intel card with the "intel" Open Source driver (xf86-video-intel) PRIME Render Offload possible with >= 435.xx NVIDIA driver with prime-select service DISABLED unset: disable effects of this script and let Xorg decide what driver to use get-current: display driver currently configured log-view: view logfile log-clean: clean logfile boot: select default card at boot or set last used next-boot: select card ONLY for next boot, it not touches your boot preference. abort: restores next boot to default get-boot: display default card at boot service: disable, check or restore prime-select service. 15:22:42 [brook@G5-openSUSE:~] $
Unfortunately this tool is not as robust as optimus-manager in Arch, especially in offering power managment options. All of the files listed in its GitHUb page are not included in the package provided by openSUSE. Despite manually including these files from a clone of the GitHub repository, and trying both versions, I was not able to have a completely working configuration in terms of power management. A screenshot of openSUSE Tumbleweed after switching from Intel to NVIDIA graphics using the proprietary drive is shown below.
Unfortunately, switching back to Intel from the point shown in the screenshot will not turn off the NVIDIA graphics.
For those who don't want to install or configure anything and can live without the performance provided by the proprietary NVIDIA driver, Fedora 32 provides the best solution. Everything including the HDMI port is functional and users are not inconvenienced by having to switch between cards and then logging out or restarting the machine.
For those who want the performance of the NVIDIA card and want to switch between cards depending on work location or performance and functionality needs, the solution provided for Arch by optimus-manager is the best. It offers multiple configuration options for the power management of the NVIDIA card and has convenient options for setting the default card. The companion app is also very full featured but I haven't tested it enough to say how reliable it is.
The PRIME Profiles switching functionality found in Kubuntu's (Ubuntu's) NVIDIA X Server Settings utility is also good and works as well as optimus-manager without having to configure anything (except in my case having to install one meta package) or use any tool besides what is provided officially by Ubuntu.