openSUSE Tumbleweed [Snapshot 20161204] Nvidia Hybrid Graphics

Jan. 1, 2017, 6 p.m.

by ORDINATECHNIC

Although openSUSE is an excellent distribution in its core design, the project's adherence to certain FOSS principles prevent it from installing proprietary packages by default. This includes packages necessary to enable the proprietary Nvidia drivers through the Nvidia kernel modules. This limitation includes the Nvidia drivers specifically used with the Bumblebee graphics processor switching program. Fortunately, openSUSE provides optional repositories that contain the necessary packages. This article describes how to enable the the full capabilities of the Intel/Nvidia hybrid system as much as it is possible in Linux on openSUSE Tumbleweed (Snapshot 20161204).

Updates

  1. The first real problem occurred with the hybrid graphics after the system was updated to kernel 4.10.1 from 4.9.11, in the manner of the warnings from the openSUSE wiki mentioned below, namely the Nvidia (for Bumblebee) kernel module was not built for this kernel. Since the Nvidia graphics on Linux are activated on a per application basis and the default graphics processor is the Intel, this wasn't even noticeable to me. Fortunately for those who have a need to use the Nvidia graphics processor, making past versions of the kernel available (which also preservers the corresponding kernel modules), as mentioned below, allows booting into a past kernel that has the appropriate kernel module.
    • slide 1
      Error messages when trying to use the Nvidia graphics processor.
      The second command shown should have been preceeded by optirun, but as the first error shows, this wouldn't have worked anyway since the necessary kernel module wasn't available for this kernel.
    • slide 2
      Installed kernels.
      The problem kernel is 4.10.1. Having some previous kernels which have the necessary corresponding kernel modules for the Nvidia (for Bumblebee) drivers available allows booting into one of these.
    • slide 3
      Installed versions of the Bumblebee kernel modules.
      Although there is a Bumblebee kernel module for the 4.10.1 kernel, there isn't an Nvidia (for Bumblebee) kernel module for this kernel as the next slide shows.
    • slide 3
      A comparison of the directories where the necessary kernel modules are written for kernels 4.10.1 and 4.9.11.
      The right pane, for 4.9.11 shows four Nvidia related kernel modules. The left pane, for 4.10.1, doesn't contain any Nvidia kernel modules. The error shown in the first slide seems to specifically refer to the missing nvidia-drm.ko.
    As warned by openSUSE Tumbleweed, Nvidia driver development and packaging are sometimes not as fast as kernel development and packaging. These slides demonstrate the issue.
    Preserving older kernels, which in turn preservers their kernel modules, allows booting into a kernel which has the necessary modules. Incidentally, the Nvidia module was not the only module not available for the 4.10.1 kernel. A comparison of the directories where modules are stored showed sparse directories for 4.10.1 compared to the older ones. I'm sure his will change as the 4.10 series progresses.
  2. A useful utility program for monitoring the Nvidia graphics processor is nvidia-smi.
    installing bumblebee on opensuse tumbleweed
    Monitoring the Nvidia graphics processor with nvidia-smi while glxgears is using it.
    optirun nvidia-smi will display the summary of the current state of the Nvidia graphics processor. optirun is necessary as otherwise only the default graphics processor is used and the command will not be able to access the GPU. nvidia-smi also has some options that will display other information.

Introduction

Many higher end laptops are built with two graphics processors -- a so called hybrid graphics system. One graphics processor is integrated in the main processor and the other is discrete. The integrated graphics processor is used for applications with less intensive graphics demands, providing the benefit of less power consumption, while the discrete graphics processor is used for applications with intensive graphics requirements, such as games, video editors, and CAD programs.

A popular hybrid graphics system is an Intel iCore main processor with an Intel integrated graphics processor and an Nvidia dedicated graphics processor. For such a system, two drivers contained in kernel modules are necessary, one to enable the integrated graphics, and another to enable the dedicated graphics. There are two options available for the Nvidia discrete processor, the open source Nouveau driver and the proprietary closed source Nvidia driver. For a hybrid system with this configuration, the openSUSE Tumbleweed installer installs and configures only the Nouveau driver -- at least this was the case when I installed Tumbleweed Snapshot 20161204 on my Acer Aspire V Nitro Black Edition (VN7-592G-70EN) -- so it is used all of the time, decreasing battery life. Unfortunately, openSUSE does not even provide users the choice to use only the open source friendly Intel driver during installation so that only the integrated Intel driver is used.

However, openSUSE makes it relatively simple to manually install and configure the proprietary Nvidia driver and the Bumblebee graphics card switching program. But, sadly in Linux, the graphics switching does not happen automatically as it does in Windows, but on a per application basis, where the Intel card is used by default and when necessary, a program can be started and instructed to use the Nvidia card.

This article discusses configuring this type of hybrid system on openSUSE Tumbleweed in order to take as full advantage of the hardware as is possible on Linux. Some precautions may be necessary as the openSUSE Tumbleweed portal warns against using the proprietary Nvidia driver with Tumbleweed because kernel developement and packaging moves faster than Nvidia driver developement and packaging, meaning that the kernel may be updated but not the Nvidia driver such that the available Nvidia driver will not work with the updated kernel. A precaution I would take to work around this situation is to make sure certain older versions of the kernel are retained after an update to allow booting into an older kernel if the updated kernel will not work with the updated driver. Note that even in this scenario, there will always be video since the integrated graphics processor is used by default in the hybrid setup.

The overall process including the zypper configuration is simple, as shown below.

Procedure

  1. Modify zypper Configuration to Retain Older Kernels after System Update

    The warning on the openSUSE Tumbleweed portal concerns the possibility of a scenario where the kernel may be updated but the Nvidia driver from which the kernel module is built is not updated. Since kernel modules are specifically built for a certain kernel version or versions, if this scenario occurs users will confront some video problems including a black screen when booting after an update. This warning only applies when using the standalone Nvidia driver because in a hybrid system the Nvidia driver is activated optionaly and secondarily to the Intel driver which is always available. Althout a user may not be confronted with a black screen, activating a program using the discrete processor will not be possible. For this situation, preserving some older kernel versions on the system will allow users to boot into an older kernel that works with the available Nvidia module until an updated Nvidia driver is available.

    1. Ensure support for multversion kernels is enabled

      To do this examine and edit the file /etc/zypp/zypp.conf. The line
      multiversion = provides:multiversion(kernel)
      should exist in the file.
    2. Specify the kernel versions relative to the latest that should be preserved

      Modify the line
      multiversion.kernels = latest,latest-1,running
      such that it is
      multiversion.kernels = latest,latest-1,latest-2,latest-3,latest-5,latest-10,running
      or whatever set of kernels you think is best. The above change will add the third, fourth, sixth, and eleventh latest kernels as those to be perserved, increasing the liklihood that a kernel that works with an unupdated Nvidia module will be available. I think this is a beneficial modification because of the very frequent and bleeding edge kernel updates in Tumbleweed, although in the past month that I have this installation it has not been necessary.

  2. Enable the Bumblebee Repository for Tumbleweed

    1. Add the Bumblebee Project openSUSE repository for Tumbleweed

      zypper ar -f -n "Bumblebee for Tumbleweed" http://download.opensuse.org/repositories/X11:/Bumblebee/openSUSE_Tumbleweed/ Bumblebee_for_Tumbleweed
    2. In the above command zypper is the command line package manager, ar is an alias for addrepo, the options -f and -n, respectively, will set the repository to refresh automatically during package management operations and set the name to the string in quotes. The URL of the repository and the alias given to the repository follow. Remember that the default priority number is 99, and that the lower priority setting number, the higher the priority of that repository. See this page for some more information on openSUSE package management.
    3. Raise the priority of the Bumblebee repository

      This is necessary to ensure that packages related to Bumblebee and the Nvidia driver package for use with Bumblebee only come from this repository.
      zypper mr -p 25 "Bumblebee for Tumbleweed"
    4. In the above command mr is an alias for modifyrepo, the option -p sets the priority to the number following it, and the string in quotes specifies by name the repository that is to be modified. See this page for some more information on openSUSE package management.

  3. Install and configure Bumblebee

    1. Install Bumblebee

      This can be done with zypper using the following command.
      zypper in bumblebee
      installing bumblebee on opensuse tumbleweed
      Installing Bumblebee on openSUSE Tumbleweed.
      Commanding zypper to install bumblebee will cause to to install the required dependencies and suggested packages, and smartly the 32-bit versions of these programs. The 32-bit versions are necessary for programs such as Skype, Steam, and maybe some others.

    2. Add User to Relevant Groups

      Add the user to the video and bumblebee groups.
      usermod -G video,bumblebee username
      Or according to the message from the packagers of Bumblebee that is displayed when installing Bumblebee:
      gpasswd -a username bumblebee
      gpasswd -a username video
      installing bumblebee on opensuse tumbleweed
      Installing Bumblebee on openSUSE Tumbleweed.
      The screenshot shows a Konsole terminal window with the packager messages during the installation of the bumblebee package. The messages instruct the user to add the user to the necessary groups and to blacklist the nouveau driver. The message must be the same one used for the standalone Nvidia driver because it doesn't instruct the user to also blacklist the standalone nvidia driver. Also note that the file mentioned for blacklisting the module is the generic /etc/modprobe.d/50-blacklist.conf, instead of /etc/modprobe.d/51-blacklist-nouveau.conf, which was created automatically at some point in the process.

    3. Enable the bumblebeed Service

      systemctl enable bumblebeed.service

  4. Install the Necessary Kernel Development Packages

    1. Install Kernel Headers

      There is more than one package that can be installed to satisfy the kernel header requirement to allow building the Nvidia proprietary driver kernel module, but I chose the simplest option in terms of determining what needs to be installed. The following seems to be the simplest option when installing, but it may make the overall system more complex with some unnecessary components.
      zypper in -t pattern devel_kernel
    2. Install dkms

      The dkms tool is necessary to build the Nvidia driver kernel module. It can be installed with
      zypper in dkms
    3. Enable the dkms Service

      systemctl enable dkms

  5. Install and Configure the Proprietary Nvidia Driver for Use with Bumblebee.

    Note that there is a specific version of the proprietary Nvidia driver for use with bumblebee. Do not use the standalone proprietary Nvidia driver. The correct version can be distinguished by the "-bumblebee" in the name, as in nvidia-bumblebee.

    1. Install the nvidia-bumblebee Package

      zypper in nvidia-bumblebee
      The screenshot shows a <samp>Konsole</samp> terminal window during the installation of <samp>nvidia-bumblebee</samp>. The first part of the output displays the progress of the Nvidia installer download from remote servers. The second part shows verification of the download and the start of uncompressing the download.
      Installing Nvidia for use with Bumblebee on openSUSE Tumbleweed.
      The screenshot shows a Konsole terminal window during the installation of nvidia-bumblebee. The first part of the output displays the progress of the Nvidia installer download from remote servers. The second part shows verification of the download and the start of uncompressing the download.
      The screenshot shows a <samp>Konsole</samp> terminal window during the installation of <samp>nvidia-bumblebee</samp>. The first part of the output displays the progress of uncompressing the Nvidia installer. The second part shows output from the kernel module building process..
      Installing Nvidia for use with Bumblebee on openSUSE Tumbleweed.
      The screenshot shows a Konsole terminal window during the installation of nvidia-bumblebee. The first part of the output displays the progress of uncompressing the Nvidia installer. The second part shows output from the kernel module building process.
    2. Install the 32-bit nvidia-bumblebee Package

      zypper in nvidia-bumblebee-32bit

  6. Ensure Conflicting Kernel Modules Are Disabled

    The kernel module used for the hybrid setup such that the graphics processor to be used is switched by Bumblebee is nvidia-bumblebee, not the standalone one used for non-hybrid setups, nvidia. This kernel module and the nouveau kernel module must be blacklisted so that the Nvidia kernel module for hybrid setups can run properly.

    1. Ensure That the nouveau and the nvidia Kernel ModulesAare Disabled.

      These modules are disbled if the entries
      blacklist nouveau
      and
      blacklist nvidia
      exist in /etc/modprobe.d/50-blacklist.conf, or in any file in /etc/modprobe.d/. I used /etc/modprobe.d/51-blacklist-nouveau.conf, which apparently, was created automatically but with only an entry for blacklisting nouveau. I only had to create an entry for the standalone nvidia kernel module.
      The standalone Nvidia kernel module and the Nouveau kernel module must be blacklisted so that the Nvidia for Bumblebee kernel module module can run properly. The screenshot shows openSUSE Tumbleweed with KDE Plasma 5. The Dolphin file manager shows files in <samp>/etc/modprobe.d/</samp> directory which are used to blacklist kernel modules. The relevant file is shown hilighted in Dolphin and open in Kwrite to the lower right of the image. Note the two lines that blacklist the Nouveau and Nvidia drivers.
      The standalone Nvidia kernel module and the Nouveau kernel module must be blacklisted so that the Nvidia for Bumblebee kernel module module can run properly.
      The screenshot shows openSUSE Tumbleweed with KDE Plasma 5. The Dolphin file manager shows files in /etc/modprobe.d/ directory which are used to blacklist kernel modules. The modprobe.d file I used is shown hilighted in Dolphin and open in Kwrite to the lower right of the image. Note the two lines that blacklist the Nouveau and Nvidia drivers.
  7. Make a New Initial Ram File System

    1. Generate a New Initrd

      Instead of using the dracut program, the simpler mkinitrd script can be used, which in turn calls dracut with simple options.
      mkinitrd

References

openSUSE Nvidia-Bumblebee wiki
https://en.opensuse.org/SDB:NVIDIA_Bumblebee
Reddit User Contributed Tutorial
https://www.reddit.com/r/openSUSE/comments/3slh7e/tumbleweed_how_to_set_up_nvidia_optimus_with_the/
Arch wiki
https://wiki.archlinux.org/index.php/Bumblebee
Biblioteka Riklaunima Blog
http://www.rkblog.rk.edu.pl/w/p/monitoring-amd-intel-and-nvidia-graphics-card-usage-under-linux/
Microway Blog
https://www.microway.com/hpc-tech-tips/nvidia-smi_control-your-gpus/

Conclusion

If everything goes as it should after following this procedure and rebooting, the integrated graphics processor will be used by default. Applications for which it is desireable to use the discrete graphics processor should be started using the optirun program.


brook@VN592G-openSUSE:~> glxgears
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
348 frames in 5.0 seconds = 69.387 FPS
301 frames in 5.0 seconds = 60.008 FPS
^C
brook@VN592G-openSUSE:~> optirun glxgears
13613 frames in 5.0 seconds = 2722.343 FPS
13456 frames in 5.0 seconds = 2691.132 FPS
13761 frames in 5.0 seconds = 2752.181 FPS
^C[  402.870734] [WARN]Received Interrupt signal.
        
The above code block demonstrates the use of optirun; the first command entered at the prompt,
glxgears
runs the framerate testing program using the default graphics processor -- the integrated one. The next command,
optirun glxgears
runs the framerate testing program using the discrete graphics processor. Running the glxgears program with and without optirun program verifies that the Nvidia driver for use with Bumblebee was installed and configured properly. Both invocations of optirun should run without error and the reported framerates should be significantly higher with optirun than without.
Verifying Proper Installation and Configuration of Intel/Nvidia Hybrid Graphics on openSUSE Tumbleweed. The screenshot shows openSUSE Tumbleweed with KDE Plasma 5. In the top left corner a <samp>Konsole</samp> terminal is showing the output of glxinfo | grep 'OpenGL renderer' and glxinfo | grep 'OpenGL renderer'. In the first case glxinfo is using the default graphics processor and shows that the Intel HD Graphics 530 is the 'OpenGL renderer'. In the second case glxinfo shows that the 'OpenGL renderer' is the [Nvidia] GeForce GTX 960M -- the discrete processor. The <samp>Konsole</samp> terminal at the lower right shows the framerates when using the discrete graphics card -- over approximately forty times higher framrates.
Verifying Proper Installation and Configuration of Intel/Nvidia Hybrid Graphics on openSUSE Tumbleweed
The screenshot shows openSUSE Tumbleweed with KDE Plasma 5. In the top left corner a Konsole terminal is showing the output of glxinfo | grep "OpenGL renderer and glxinfo | grep "OpenGL renderer". In the first case glxinfo is using the default graphics processor and shows that the Intel HD Graphics 530 is the "OpenGL renderer". In the second case glxinfo shows that the "OpenGL renderer" is the [Nvidia] GeForce GTX 960M -- the discrete processor. The Konsole terminal at the lower right shows the framerates when using the discrete graphics card -- over approximately forty times higher framrates.

For anyone who has a need for the best possible graphics performance in certain applications and wants to use openSUSE, this procedure is worthwile. Note the significant difference in framerates between the integrated graphics processor and the discrete graphics processor. The gain in battery life by using the Intel graphics driver instead of the default open source Nvidia driver -- Nouveau -- should also be a motivator in using this procedure. In my case battery life doubled on the Acer Aspire V Nitro Black Edition (VN7-592G-70EN).

Also good news for fans of openSUSE Tumbleweed is that, of the three distributions that I have used on this laptop with Nvidia hybrid graphics, openSUSE performed best. I set up Nvidia with Bumblebee on Ubuntu 16.04, but although the optirun test pictured above works, the frame rates were no different than when using the integrated graphics. Additionally, with Ubuntu some Nvidia configuration files needed to be edited during installation and after update. On the other distribution I have used on this computer, Manjaro, which impressively configures Nvidia with Bumblebee automatically during installation, the optirun test results were the same as with Ubuntu -- same framerates with or without the discrete graphics processor.

Despite Tumbleweed's sometimes frequent updates, so far after two or three kernel minor version updates and one kernel major version update, one Nvidia driver for Bumblebee update, and several Bumblebee updates over the past month, the worst case scenario mentioned above hasn't occured. The only problems that occured were very minor such as the need to re-enable the bumblebeed service once, and the need to reboot once after the kernel major version update before the Nvidia processor could be found when running a program with optirun. In all of these cases during boot the integrated card was used by default so there was not the catastrophic black screen situation.

blog comments powered by Disqus