PCsuggest

  • Quick tip
  • SECURITY
  • NETWORKING
  • OpenWrt
  • HARDWARE

NVIDIA Optimus troubleshooting in Debain, Kali Linux

Updated - July 17, 2018 by Arnab Satapathi

Though bumblebee and NVIDIA Optimus drivers are stable enough now, still you may face some problem after successfully installing them in Debian.

This tutorial is an extension of the previous, configure NVIDIA optimus in Debian, Kali Linux , specially for troubleshooting purpose, this guide also applies on any Debian derivative like Kali Linux, LMDE, SolydXK and so on.

I never faced any major problem with recent non-free drivers, bumblebee packages and recent kernel, using a NVIDIA GEFORCE GT 540M card. Problems listed bellow are faced by some other guys, and they left comments on the previous tutorial. I really appreciate those comments.

Contents

  • 1. optirun glxgears returns /dev/dri/card0 failed to set drm interface
  • 2. Optirun taking longer time to access the NVIDIA graphics card
  • 3. modprobe failed to remove nouveau module
  • 4. bbswitch failed to load and turn off discrete NVIDIA card

1. optirun glxgears returns /dev/dri/card0 failed to set drm interface

An older kernel version with relatively newer nvidia driuver could be the reason of this problem.

So first update and upgrade all the packages, including kernel, then try again with optirun.

sudo apt-get update && apt-get dist-upgrade

Another reason: Optirun may return errors sometime like this >  /dev/dri/card0 failed to set drm interface 1.4 permission denied . For this edit the /etc/bumblebee/xorg.conf.nvidia file, this is the X11 configuration file used by bumblebee. Add those extra configuration options there,

Section "Screen"
Identifier "Default Screen"
Device "DiscreteNvidia"
EndSection

after this restart bumblebee and try again.

sudo service bumblebeed restart

2. Optirun taking longer time to access the NVIDIA graphics card

Optirun may take 6-10 seconds to initialize everything at first run, but next it should take 1.5 seconds to maximum 2 seconds to start an application using the discrete GPU. If you are facing the same delay like the first run, add the boot time kernel parameter bellow to the /etc/default/grub file just after the quiet word.

rcutree.rcu_idle_gp_delay=1

It should look like bellow,

GRUB_CMDLINE_LINUX_DEFAULT="quiet rcutree.rcu_idle_gp_delay=1"

Now update the grub configuration

amazon prime logo
Try AmazonPrime for free
Enjoy free shipping and One-Day delivery, cancel any time.
sudo update-grub

Now restart the laptop and check again if optirun is delaying to start apps. Check if the new configuration took effect or not.

cat /sys/module/rcutree/parameters/rcu_idle_gp_delay

It should return 1 , this issue seems like to be fixed in recent Linux kernels.

3. modprobe failed to remove nouveau module

While running the command modprobe -r nouveau , the system may fail to remove the nouveau module, returning an error message like modprobe:FATAL:Module nouveau in use. For this, you need to tell the kernel that not to use nouveau for kernel mode setting(KMS). Read more about KMS here.

Easy workaround, first install bumblebee, it may take care of everything or may not.

Still if you are facing the same issue, add the kernel parameters, nouveau.modeset=0 and modprobe.blacklist=nouveau to /etc/default/grub , just like above, it should look like bellow,

GRUB_CMDLINE_LINUX_DEFAULT="quiet nouveau.modeset=0 modprobe.blacklist=nouveau bla bla bla"

Wath out the bla bla bla, just example, update the grub rescue configuration and reboot the system.

sudo update-grub

Now reboot the laptop and  and  try to unload nouveau module again. If no luck still, delete/move the nouveau kernel module and reboot, stupid but this will definitely work.

sudo mv /lib/modules/4.2.0-16-generic/kernel/drivers/gpu/drm/nouveau/nouveau.ko /usr/src

Note: If modprobe -r command not working, then try the rmmod command.

4. bbswitch failed to load and turn off discrete NVIDIA card

Sometimes  Make sure every nvidia related kernel modules like nouveau, nvidia, nvidia_uvm are unloaded and try to load bbswitch again.

sudo rmmod nvidia_uvm
sudo rmmod nvidia
sudo rmmod nouveau
sudo modprobe bbswitch load_state=0

Add the acpi_backlight=vendor kernel parameter to grub configuration, this may help.

GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_backlight=vendor"

Update the grub configuration with sudo update-grub and reboot and try again to insert the bbswitch module.


Those solutions/fixes listed above may or may not work, surely you will find some workaround by experimenting with different configurations.

Recommended readings

  • https://wiki.debian.org/Bumblebee
  • http://bumblebee-project.org/install.html
  • https://wiki.archlinux.org/index.php/bumblebee

Everyone is highly encouraged to leave their valuable comment/suggestion, it might solve someone else's nvidia optimus related problem.

Filed Under: how to Tagged With: gpu, nvidia, nvidia optimus

Your comments
  1. Guilherme TW says

    March 28, 2019

    [ 141.056512] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf
    [ 141.056817] [DEBUG]optirun version 3.2.1 starting...
    [ 141.056841] [DEBUG]Active configuration:
    [ 141.056854] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
    [ 141.056866] [DEBUG] X display: :8
    [ 141.056889] [DEBUG] LD_LIBRARY_PATH: /usr/lib/x86_64-linux-gnu/nvidia:/usr/lib/i386-linux-gnu/nvidia:/usr/lib/nvidia
    [ 141.056896] [DEBUG] Socket path: /var/run/bumblebee.socket
    [ 141.056902] [DEBUG] Accel/display bridge: auto
    [ 141.056909] [DEBUG] VGL Compression: proxy
    [ 141.056916] [DEBUG] VGLrun extra options:
    [ 141.056934] [DEBUG] Primus LD Path: /usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus:/usr/lib/primus:/usr/lib32/primus
    [ 141.057365] [DEBUG]Using auto-detected bridge virtualgl
    [ 141.156040] [INFO]Response: No - error: Could not load GPU driver

    [ 141.156108] [ERROR]Cannot access secondary GPU - error: Could not load GPU driver

    [ 141.156138] [DEBUG]Socket closed.
    [ 141.156180] [ERROR]Aborting because fallback start is disabled.
    [ 141.156197] [DEBUG]Killing all remaining processes.

    Reply
  2. Matiux says

    December 9, 2018

    I followed your guide: https://www.pcsuggest.com/install-and-configure-nvidia-optimus-with-bumblebee-in-debian/

    I'm on debian testing with Nvidia MX150 and Linux 4.18.20-2

    When I run optirun -vv glxgears I get this error:

    [ 307.530733] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf
    [ 307.531441] [DEBUG]optirun version 3.2.1 starting...
    [ 307.531466] [DEBUG]Active configuration:
    [ 307.531473] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
    [ 307.531480] [DEBUG] X display: :8
    [ 307.531486] [DEBUG] LD_LIBRARY_PATH: /usr/lib/x86_64-linux-gnu/nvidia:/usr/lib/i386-linux-gnu/nvidia:/usr/lib/nvidia
    [ 307.531492] [DEBUG] Socket path: /var/run/bumblebee.socket
    [ 307.531498] [DEBUG] Accel/display bridge: auto
    [ 307.531504] [DEBUG] VGL Compression: proxy
    [ 307.531510] [DEBUG] VGLrun extra options:
    [ 307.531521] [DEBUG] Primus LD Path: /usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus:/usr/lib/primus:/usr/lib32/primus
    [ 307.531600] [DEBUG]Using auto-detected bridge virtualgl
    [ 308.357835] [INFO]Response: Yes. X is active.

    [ 308.357849] [INFO]Running application using virtualgl.
    [ 308.357951] [DEBUG]Process vglrun started, PID 2417.
    libGL error: No matching fbConfigs or visuals found
    libGL error: failed to load driver: swrast
    X Error of failed request: GLXBadContext
    Major opcode of failed request: 154 (GLX)
    Minor opcode of failed request: 6 (X_GLXIsDirect)
    Serial number of failed request: 34
    Current serial number in output stream: 33
    [ 308.452768] [DEBUG]SIGCHILD received, but wait failed with No child processes
    [ 308.452793] [DEBUG]Socket closed.
    [ 308.452807] [DEBUG]Killing all remaining processes.

    Reply
    • Arnab Satapathi says

      December 9, 2018

      TBH, MX150 card is fairly new, and I highly doubt that it will be supported by Debian that early.

      Reply
      • Matiux says

        December 9, 2018

        I have bought this notebook (dell inspiron 15 7000) because I have previously that this card is supported https://www.nvidia.it/Download/driverResults.aspx/140239/it. Is according to you a compatibility hardware problem?

        Reply
        • Matiux says

          December 10, 2018

          *I have previously seen

          Reply
  3. Nick says

    January 6, 2018

    Following both your guides, still running into issues made a post on superuser (much easier to follow then a really long comment). If you could be of any assistance it would be very much appreciated.

    superuser.com/questions/1282984/conundrum-dell-xps-15-kali-linux-hanging-post-nvidia-drivers-installation

    Reply
    • Arnab Satapathi says

      January 6, 2018

      Hi Nick, unfortunately it's showing page not found on SU.

      Reply
  4. Chris Sl. says

    March 17, 2017

    I forgot to mention in my last comment in part "3" that every game/app I tested with primusrun was done with virtualgl uninstalled.

    Reply
    • Arnab Satapathi says

      March 17, 2017

      Received your mail, and edited the comment section CSS, thanks for the tip.

      Reply
      • Chris Sl. says

        March 18, 2017

        No problem! Anyway, any thoughts about 2 and 3?

        Reply
        • Arnab Satapathi says

          March 18, 2017

          I'll test the Unigine Heaven benchmarking tool with and without VirtualGL, and will compair their performance, on monday evening, out of time this week. I'm so impressed by your patience !

          Reply
          • Chris Sl. says

            March 18, 2017

            Well, it is the only thing that makes me having dual boot. I am a bit gamer and I want to enjoy my games in linux as well and while I have no problem in not being able to run them all flawlessly via Wine I do care in being able to use my discrete graphics (and not for game only but for heavy apps as well).

            Anyway, if we manage to shed some light in the whole nvidia optimus problem it might help other linux comrades as well!

  5. Chris Sl. says

    March 14, 2017

    Hi,
    first of all thanks for sharing this great tutorial with us. I was trying for ages to make my nvidia graphics to work and now thanks to you it finally does! Thank you, sir!

    However, I encountered two very odd problems.

    1) I am trying to play Europa Universalis 4 but it gives me the following error when I try it to run it with virtualgl_2.5.2_amd64 installed:
    ERROR: ld.so: object 'libdlfaker.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
    ERROR: ld.so: object 'libvglfaker.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.
    X Error of failed request: BadValue (integer parameter out of range for operation)
    Major opcode of failed request: 155 (GLX)
    Minor opcode of failed request: 3 (X_GLXCreateContext)
    Value in failed request: 0x0
    Serial number of failed request: 73
    Current serial number in output stream: 74

    When I try to run the game with virtualgl_2.5.2_i386 installed I get:

    ERROR: ld.so: object 'libdlfaker.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
    ERROR: ld.so: object 'libvglfaker.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
    ./eu4: error while loading shared libraries: libXv.so.1: cannot open shared object file: No such file or directory

    Note 1: I found some threads mentioning a possible fix in case the game is installed via steam. This is not the case. My game is a "standalaone" installation that does not need steam installed to run.

    Note 2: If I uninstall virtualgl at all then the game runs normally. How is this possible? I know virtualgl is for bridging but I am not sure how this works.

    2) I ran once chromium with "optirun chromium" (for testing purposes) but since then chromium always run with nvidia instead of my intel integrated graphics.
    I thought nvidia graphics are activated for a program only if called via 'optirun program_name'. Did I missed something?

    Thanks in advance for any tips/help/response.

    Chris Sl.

    Reply
    • Arnab Satapathi says

      March 15, 2017

      Hi Chris, sorry for being late.

      As of your issue with Chromium, try after removing the configuration folder to a different location, it's located at ~/.config/chromium/

      Wrong ELF class, that's a 32 bit and 64 bit shared library conflict, you may need to install whole 32 bit NVIDIA stuff.

      When there's no VirtualGL, perhaps it's using the NVIDIA card by default. check that with lspci -v | grep -i 'vga' | grep -i 'nvidia' or with the cat /proc/acpi/bbswitch command if bbswitch module is installed.

      Are you running this game through wine ? Then you're also going to need all relevant 32 bit wine libraries.

      Reply
      • Chris Sl. says

        March 16, 2017

        Hi and thanks for the reply!

        In Chromium if I rename/move the ~/.config/chromium/ folder then Chromium starts with "factory settings" as expected and in chrome://gpu my Intel integrated graphics are selected. However, when I restore the folder with my settings the Nvidia graphics are selected every time I run Chromium.

        About EU4 now. The game is not running through wine or other windows emulator. Is a native linux version.
        The output of lspci -v | grep -i 'vga' | grep -i 'nvidia' is:
        01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 640M] (rev ff) (prog-if ff)

        So, is VirtualGL really useful? I really don't understand the bridge thing and how it works... If I just want to run some programs with optirun, do I really need the bridging? Also, by following your tutorial primus is getting installed anyway and I think it is used for the same job.

        Reply
        • Arnab Satapathi says

          March 16, 2017

          As of my understanding about VirtualGL, it's really useful when you've a multi monitor setup, or some thin clients. Read more about it if you've got some free time, http://www.virtualgl.org/About/Background .

          But in case of NVIDIA optimus, VirtualGL is just a workaround to process and render graphics intensive contents on the laptops display.

          And of course, if the application supports accelerated rendering through primus, you should use it for better performance.

          Reply
          • Chris Sl. says

            March 17, 2017

            Hi again!

            1. I solved the Chromium problem without having to "hard reset" it by only deleting the Local State file in ~/.config/chromium/

            2. About VirtualGL, While I understand its usefulness why is necessary for a simple user that just wants his nvidia to work if bumblebee installs primus as well? Also, can you test and confirm/bust if any native or wine 3D apps/games you have work without virtualgl as well?

            3. I tested several games with 'primusrun ' and all seem to work. However, everytime I run something with primusrun even everything seems to work as expected I get the following warning "/usr/bin/primusrun: line 41: warning: command substitution: ignored null byte in input"

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © PCsuggest.com · All rights reserved.

  • Home
  • About
  • Contact
  • Privacy Policy
  • Sitemap