question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switching to NVIDIA GPU does not work after suspend

See original GitHub issue

Describe the bug I recently did a reinstall of my system and now I can’t get switching to the NVIDIA GPU to work reliably anymore. It works just fine after rebooting, but once I suspend the system while in Intel mode, the NVIDIA GPU won’t turn on again when trying to switch to it. I had been using switching=bbswitch just fine for ~2 years, since this was the only configuration that was working with my laptop model.

Unfortunately I can’t really tell if this started with the reinstall itself, a newer version of optimus-manager, a NVIDIA driver update or something else. I just noticed it after the reinstall while testing if optimus-manager works. I also upgraded the BIOS firmware recently, but downgrading it again did not resolve the issue, so I’d rule that out.

System info Laptop Model: Dell XPS 15 9560 OS: Arch Linux Kernel: 5.7.7-arch1-1 KDE Plasma: 5.19.3 SDDM: 0.18.1 bspwm: 0.9.9 optimus-manager: 1.3.1

optimus-manager.conf:

[optimus]
switching=bbswitch
pci_power_control=no
pci_remove=no
pci_reset=no

Only had the first two lines in there before the reinstall, but different values for the settings below do not make a difference. I also tried switching=acpi_call but that did not help either.

Logs optimus-manager --status output:

ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20200712T134536.log

Cannot execute command because of previous errors.

/var/log/optimus-manager/switch/switch-20200712T134536.log:

[17] INFO: # Xorg pre-start hook
[17] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'nvidia', 'current_mode': 'intel'}
[17] INFO: Requested mode is: nvidia
[17] INFO: Checking for GDM display servers
[796] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[796] INFO: Unloading modules ['nouveau'] (if loaded)
[799] INFO: Loading module bbswitch
[801] INFO: Setting GPU power to ON via bbswitch
[829] INFO: Loading module nvidia
[1557] ERROR: Xorg pre-start setup error
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/bash.py", line 11, in exec_bash
    out = subprocess.check_output(
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['bash', '-c', 'modprobe nvidia NVreg_UsePageAttributeTable=1']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 179, in _load_module
    exec_bash("modprobe %s %s" % (module, options))
  File "/usr/lib/python3.8/site-packages/optimus_manager/bash.py", line 18, in exec_bash
    raise BashError(
optimus_manager.bash.BashError: Failed to execute 'modprobe nvidia NVreg_UsePageAttributeTable=1' :
modprobe: ERROR: could not insert 'nvidia': No such device


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 45, in main
    setup_kernel_state(config, prev_state, requested_mode)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 21, in setup_kernel_state
    _nvidia_up(config)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 56, in _nvidia_up
    _load_nvidia_modules(config, available_modules)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 109, in _load_nvidia_modules
    _load_module(available_modules, "nvidia", options="NVreg_UsePageAttributeTable=%d" % pat_value)
  File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 181, in _load_module
    raise KernelSetupError("error running modprobe for %s : %s" % (module, str(e)))
optimus_manager.kernel.KernelSetupError: error running modprobe for nvidia : Failed to execute 'modprobe nvidia NVreg_UsePageAttributeTable=1' :
modprobe: ERROR: could not insert 'nvidia': No such device

[1557] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[1558] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20200712T134536', 'requested_mode': 'nvidia'}

Part of dmesg output:

[  248.049467] bbswitch: enabling discrete graphics
[  248.049482] pci 0000:01:00.0: can't change power state from D3cold to D0 (config space inaccessible)
[  248.051760] pci 0000:01:00.0: can't change power state from D3cold to D0 (config space inaccessible)
[  248.674732] nvidia-nvlink: Nvlink Core is being initialized, major device number 236
[  248.675238] NVRM: This is a 64-bit BAR mapped above 4GB by the system
               NVRM: BIOS or the Linux kernel, but the PCI bridge
               NVRM: immediately upstream of this GPU does not define
               NVRM: a matching prefetchable memory window.
[  248.675239] NVRM: This may be due to a known Linux kernel bug.  Please
               NVRM: see the README section on 64-bit BARs for additional
               NVRM: information.
[  248.675242] nvidia: probe of 0000:01:00.0 failed with error -1
[  248.675265] NVRM: The NVIDIA probe routine failed for 1 device(s).
[  248.675265] NVRM: None of the NVIDIA devices were initialized.
[  248.675729] nvidia-nvlink: Unregistered the Nvlink Core, major device number 236

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Dzjedcommented, Oct 15, 2020

Thank you, @Askannz! Now it works again without the systemd-sleep script.

0reactions
beyond9thousandcommented, Dec 27, 2021

I integrated the systemd-sleep script solution to optimus-manager, let me know if it fixes your issue (It also fixed a bunch of issues related to the Nvidia GPU waking up by itself after suspend, which is nice !).

I am experiencing the same issue right now. It was working fine after the first install but it doesn’t work anymore. Any suggestions?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not Coming Back From Suspend - Linux
If you do want to try the new suspend path, the only requirements are to set NVreg_PreserveVideoMemoryAllocations=1 and then be sure to trigger ......
Read more >
Desktop session doesn't survive suspend after changing to ...
I recently changed from AMD to NVidia for graphics and since then my desktop session doesn't survive suspend. When waking my machine up ......
Read more >
Resume fail after suspend with NVIDIA driver on Ubuntu 22.04
After upgrading from 21.10 to 22.04, the suspend/resume stopped working on my laptop with an NVIDIA discrete card.
Read more >
How do I fix CUDA breaking after suspend? - Ask Ubuntu
Create /etc/modprobe.d/nvidia-power-management.conf with options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/tmp .
Read more >
Fedora 34 KDE unable to suspend after nvidia driver update
The problem seems to be related to inactive systemd units which I enabled like be found in Chapter 21. Configuring Power Management Support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found