Setting Up NVIDIA Optimus on Debian 10

New to Debian (Or Linux in general)? Ask your questions here!

Setting Up NVIDIA Optimus on Debian 10

Postby rplee » 2020-06-13 22:24

I have an ACER AN515-51 gaming laptop with these specs:

    Integrated GPU: 7th Generation Intel Core i5-7300HQ Processor (Up to 2.5 GHz)
    Dedicated GPU: NVIDIA GeForce GTX 1050 Ti with 4 GB of dedicated GDDR5 VRAM
    Memory: 8GB DDR4 RAM
    256GB Intel SSD

ISSUE:


I just installed Debian 10.4 Buster with Cinnamon. It's a dual boot machine with Windows 10 which came pre-installed. In order to fix a freezing issue whenever I rebooted/shut down through GUI or opened Firefox, I disabled nouveau kernel drivers. This fixed the freezing issue. Then I updated my kernel from 4.19.0-9-amd64 to 5.5.0-0.bpo.2-amd64 and also installed the matching kernel header files. After that, I tried to install NVIDIA proprietary drivers and also set up NVIDIA Optimus, so that I could increase my frame rate (which was 40-50 fps) and utilize the greater performance of the NVIDIA drivers. However, after I tried installing the drivers, I realized that the drivers wouldn't load because when Secure Boot is enabled, Debian activates "lockdown" mode. Debian won't load kernel modules that are not signed by a trusted key, so this will block out-of-tree modules including DKMS-managed drivers, such as NVIDIA proprietary drivers.

Now, there's probably a way to install the NVIDIA drivers via Debian repository with Secure Boot enabled, but as a beginner, I don't know how to do this. I know that I would need to create a signing key for modules and add its certificate to the trusted list using MOK, basically a self signing certificate. However, the instructions on the Debian Wiki for how to create a self-signing certificate don't tell you how to install NVIDIA drivers from the Debian repository using that certificate. I couldn't find it elsewhere online either, though I did find some instructions on how to install the drivers from the NVIDIA website on Ubuntu. I also didn't know whether or not I would have to manually reinstall the drivers every time I update the kernel, even if I install the drivers via Debian repository, because of the Secure Boot issue.

So ultimately, I decided it's easier to just disable Secure Boot. So I disabled Secure Boot, and installed the proprietary NVIDIA drivers via Debian repository. I then followed the instructions under the "Using NVIDIA GPU as the primary GPU" section: https://wiki.debian.org/NVIDIA%20Optimus

Then I ran these commands:
Code: Select all
$ inxi -G
           Graphics:  Device-1: Intel HD Graphics 630 driver: i915 v: kernel
           Device-2: NVIDIA GP107M [GeForce GTX 1050 Ti Mobile] driver: nvidia v: 440.82
           Display: x11 server: X.Org 1.20.4 driver: modesetting,nvidia resolution: 1920x1080~60Hz
           OpenGL: renderer: GeForce GTX 1050 Ti/PCIe/SSE2 v: 4.6.0 NVIDIA 440.82


Code: Select all
$ lspci -k | grep -A 2 -i "VGA"
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
    Subsystem: Acer Incorporated [ALI] HD Graphics 630
    Kernel driver in use: i915
--
01:00.0 VGA compatible controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Ti Mobile] (rev a1)
    Subsystem: Acer Incorporated [ALI] GP107M [GeForce GTX 1050 Ti Mobile]
    Kernel driver in use: nvidia


Code: Select all
$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: GeForce GTX 1050 Ti/PCIe/SSE2


Code: Select all
$dpkg -l | grep -i nvidia
ii  glx-alternative-nvidia                 1.1.0~bpo10+1                                amd64        allows the selection of NVIDIA as GLX provider
ii  libegl-nvidia0:amd64                   440.82-1~bpo10+1                             amd64        NVIDIA binary EGL library
ii  libegl-nvidia0:i386                    440.82-1~bpo10+1                             i386         NVIDIA binary EGL library
ii  libgl1-nvidia-glvnd-glx:amd64          440.82-1~bpo10+1                             amd64        NVIDIA binary OpenGL/GLX library (GLVND variant)
ii  libgl1-nvidia-glvnd-glx:i386           440.82-1~bpo10+1                             i386         NVIDIA binary OpenGL/GLX library (GLVND variant)
ii  libgles-nvidia1:amd64                  440.82-1~bpo10+1                             amd64        NVIDIA binary OpenGL|ES 1.x library
ii  libgles-nvidia1:i386                   440.82-1~bpo10+1                             i386         NVIDIA binary OpenGL|ES 1.x library
ii  libgles-nvidia2:amd64                  440.82-1~bpo10+1                             amd64        NVIDIA binary OpenGL|ES 2.x library
ii  libgles-nvidia2:i386                   440.82-1~bpo10+1                             i386         NVIDIA binary OpenGL|ES 2.x library
ii  libglx-nvidia0:amd64                   440.82-1~bpo10+1                             amd64        NVIDIA binary GLX library
ii  libglx-nvidia0:i386                    440.82-1~bpo10+1                             i386         NVIDIA binary GLX library
ii  libnvidia-cbl:amd64                    440.82-1~bpo10+1                             amd64        NVIDIA binary Vulkan ray tracing (cbl) library
ii  libnvidia-cfg1:amd64                   440.82-1~bpo10+1                             amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-eglcore:amd64                440.82-1~bpo10+1                             amd64        NVIDIA binary EGL core libraries
ii  libnvidia-eglcore:i386                 440.82-1~bpo10+1                             i386         NVIDIA binary EGL core libraries
ii  libnvidia-fatbinaryloader:amd64        440.82-1~bpo10+1                             amd64        NVIDIA FAT binary loader
ii  libnvidia-glcore:amd64                 440.82-1~bpo10+1                             amd64        NVIDIA binary OpenGL/GLX core libraries
ii  libnvidia-glcore:i386                  440.82-1~bpo10+1                             i386         NVIDIA binary OpenGL/GLX core libraries
ii  libnvidia-glvkspirv:amd64              440.82-1~bpo10+1                             amd64        NVIDIA binary Vulkan Spir-V compiler library
ii  libnvidia-glvkspirv:i386               440.82-1~bpo10+1                             i386         NVIDIA binary Vulkan Spir-V compiler library
ii  libnvidia-legacy-390xx-glcore:amd64    390.132-3~deb10u1                            amd64        NVIDIA binary OpenGL/GLX core libraries (390xx legacy version)
ii  libnvidia-legacy-390xx-ml1:amd64       390.132-3~deb10u1                            amd64        NVIDIA Management Library (NVML) runtime library (390xx legacy version)
ii  libnvidia-ml1:amd64                    440.82-1~bpo10+1                             amd64        NVIDIA Management Library (NVML) runtime library
ii  libnvidia-ptxjitcompiler1:amd64        440.82-1~bpo10+1                             amd64        NVIDIA PTX JIT Compiler
ii  libnvidia-rtcore:amd64                 440.82-1~bpo10+1                             amd64        NVIDIA binary Vulkan ray tracing (rtcore) library
ii  nvidia-alternative                     440.82-1~bpo10+1                             amd64        allows the selection of NVIDIA as GLX provider
ii  nvidia-detect                          418.113-1                                    amd64        NVIDIA GPU detection utility
ii  nvidia-driver                          440.82-1~bpo10+1                             amd64        NVIDIA metapackage
ii  nvidia-driver-bin                      440.82-1~bpo10+1                             amd64        NVIDIA driver support binaries
ii  nvidia-driver-libs:amd64               440.82-1~bpo10+1                             amd64        NVIDIA metapackage (OpenGL/GLX/EGL/GLES libraries)
ii  nvidia-driver-libs:i386                440.82-1~bpo10+1                             i386         NVIDIA metapackage (OpenGL/GLX/EGL/GLES libraries)
ii  nvidia-driver-libs-i386:i386           440.82-1~bpo10+1                             i386         NVIDIA metapackage (OpenGL/GLX/EGL/GLES 32-bit libraries)
ii  nvidia-egl-common                      440.82-1~bpo10+1                             amd64        NVIDIA binary EGL driver - common files
ii  nvidia-egl-icd:amd64                   440.82-1~bpo10+1                             amd64        NVIDIA EGL installable client driver (ICD)
ii  nvidia-egl-icd:i386                    440.82-1~bpo10+1                             i386         NVIDIA EGL installable client driver (ICD)
ii  nvidia-installer-cleanup               20151021+9                                   amd64        cleanup after driver installation with the nvidia-installer
ii  nvidia-kernel-common                   20151021+9                                   amd64        NVIDIA binary kernel module support files
ii  nvidia-kernel-dkms                     440.82-1~bpo10+1                             amd64        NVIDIA binary kernel module DKMS source
ii  nvidia-kernel-support                  440.82-1~bpo10+1                             amd64        NVIDIA binary kernel module support files
ii  nvidia-legacy-390xx-alternative        390.132-3~deb10u1                            amd64        allows the selection of NVIDIA as GLX provider (390xx legacy version)
ii  nvidia-legacy-390xx-kernel-dkms        390.132-3~deb10u1                            amd64        NVIDIA binary kernel module DKMS source (390xx legacy version)
ii  nvidia-legacy-390xx-kernel-support     390.132-3~deb10u1                            amd64        NVIDIA binary kernel module support files (390xx legacy version)
ii  nvidia-legacy-390xx-vdpau-driver:amd64 390.132-3~deb10u1                            amd64        Video Decode and Presentation API for Unix - NVIDIA driver (390xx legacy)
ii  nvidia-legacy-check                    440.82-1~bpo10+1                             amd64        check for NVIDIA GPUs requiring a legacy driver
ii  nvidia-modprobe                        418.56-1                                     amd64        utility to load NVIDIA kernel modules and create device nodes
ii  nvidia-persistenced                    418.56-1                                     amd64        daemon to maintain persistent software state in the NVIDIA driver
ii  nvidia-settings                        440.64-1~bpo10+1                             amd64        tool for configuring the NVIDIA graphics driver
ii  nvidia-settings-legacy-390xx           390.116-1                                    amd64        tool for configuring the NVIDIA graphics driver (390xx legacy version)
ii  nvidia-support                         20151021+9                                   amd64        NVIDIA binary graphics driver support files
ii  nvidia-vdpau-driver:amd64              440.82-1~bpo10+1                             amd64        Video Decode and Presentation API for Unix - NVIDIA driver
ii  nvidia-vulkan-common                   440.82-1~bpo10+1                             amd64        NVIDIA Vulkan driver - common files
ii  nvidia-vulkan-icd:amd64                440.82-1~bpo10+1                             amd64        NVIDIA Vulkan installable client driver (ICD)
ii  nvidia-vulkan-icd:i386                 440.82-1~bpo10+1                             i386         NVIDIA Vulkan installable client driver (ICD)
ii  nvidia-xconfig                         418.56-1                                     amd64        deprecated X configuration tool for non-free NVIDIA drivers
ii  xserver-xorg-video-nvidia              440.82-1~bpo10+1                             amd64        NVIDIA binary Xorg driver
ii  xserver-xorg-video-nvidia-legacy-390xx 390.132-3~deb10u1                            amd64        NVIDIA binary Xorg driver (390xx legacy version)


Code: Select all
$ sudo dmesg | egrep -i "bbswitch|nvidia"
[    3.501337] nvidia: loading out-of-tree module taints kernel.
[    3.501345] nvidia: module license 'NVIDIA' taints kernel.
[    3.509534] nvidia: module verification failed: signature and/or required key missing - tainting kernel
[    3.517669] nvidia-nvlink: Nvlink Core is being initialized, major device number 245
[    3.519659] nvidia 0000:01:00.0: enabling device (0406 -> 0407)
[    3.519777] nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[    3.619355] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  440.82  Wed Apr  1 20:04:33 UTC 2020
[    3.753419] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  440.82  Wed Apr  1 19:41:29 UTC 2020
[    3.869808] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[    3.869810] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 1
[    4.994554] input: HDA NVidia HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input19
[    4.994585] input: HDA NVidia HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input20
[    4.994613] input: HDA NVidia HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input21
[    4.994638] input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input22


It appears that now my NVIDIA GPU is the one that's being used by default as my primary GPU. And when I play Starcraft Remastered (I installed Crossover 18.5.00 and then Blizzard Battle.net Desktop App then Starcraft Remastered), I get a frame rate of over 300 FPS without Real Time Lighting and 180-190 FPS with Real Time Lighting on.

However, now my laptop gets pretty hot, and I want to be able to switch back to Intel GPU easily. I'm aware of some of the options in other distros where you can switch between the Intel GPU and NVIDIA GPU easily. For Ubuntu, you can do this through a panel icon (mate-optimus), through the terminal (prime-select) or through NVIDIA X Server app (nvidia-settings). For Manjaro, you can do this through an applet (optimus-switch). For Archlinux and Archlinux-based distros, you can do this through optimus-manager. However, it's a bit trickier to get NVIDIA Optimus working properly for Debian. Yes, there's Bumblebee, but there are performance issues, and it doesn't officially support Vulkan games. I doubt I'll get 300 FPS in Starcraft Remastered with Bumblebee. Ideally, I want to set it up so that it's as close as possible to how NVIDIA Optimus works in Windows (be able to switch from Intel GPU to NVIDIA GPU easily even if not automatically) and also be able to play Vulkan games.

Summary of the options I considered to set up NVIDIA Optimus: https://www.reddit.com/r/linux_gaming/c ... a_optimus/

1. PRIME and PRIME synchronization
Pros: Good performance
Cons: Requires you to log out and log back in

2. nvidia-xrun
Pros: Best performance; Can be used in combination with Bumblebee
Cons: Requires a separate X server that will run in a virtual terminal (tty); More difficult to set up; Not packaged for Debian

3. Bumblebee
Pros: Allows you to launch apps on the NVIDIA GPU while using the Intel GPU by default; Doesn't require you to log out and log back in
Cons: Performance is not as good as NVIDIA Prime or nvidia-xrun; "Obsolete" and not currently being maintained; Doesn't officially support Vulkan API, but can run Vulkan games with `primus_vk`; Also doesn't support Steam; Enforces vsync which can be bypassed but if bypassed, might cause screen tearing
rplee
 
Posts: 1
Joined: 2020-06-13 21:47

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 12 guests

fashionable