Start Intel (OK); Switch NVIDIA (OK); Switch Intel (OK); no more switching: modprobe: FATAL: Module nvidia is in use.
See original GitHub issueDescribe the bug Thanks for this project! I’m switching from bumblebee.
I can switch from Intel to NVIDIA and back to Intel once more, but the nvidia
module doesn’t get unloaded, and optimus-manager
won’t do anything more, complaining that the Xorg pre-start hook failed (logs below).
System info
- Arch Linux
- KDE Plasma
- SDDM
- optimus-manager 1.3
/etc/optimus-manager/optimus-manager.conf
(I think this is still as default):
[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=
[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
ignore_abi=no
modeset=yes
options=overclocking
[optimus]
auto_logout=yes
pci_power_control=no
pci_remove=no
pci_reset=no
startup_auto_battery_mode=intel
startup_auto_extpower_mode=nvidia
startup_mode=intel
switching=none
Logs
$ optimus-manager --status
ERROR: the latest GPU setup attempt failed at Xorg pre-start hook.
Log at /var/log/optimus-manager/switch/switch-20200621T142717.log
Cannot execute command because of previous errors.
Best of /var/log/optimus-manager/switch/switch-20200621T142717.log
:
subprocess.CalledProcessError: Command '['bash', '-c', 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia']' returned non-zero exit status 1.
optimus_manager.bash.BashError: Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.
optimus_manager.kernel.KernelSetupError: Cannot unload modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] : Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.
Full log
[10] INFO: # Xorg pre-start hook
[10] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'intel', 'current_mode': 'nvidia'}
[10] INFO: Requested mode is: intel
[10] INFO: Checking for GDM display servers
[890] INFO: Available modules: ['nouveau', 'bbswitch', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[890] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] (if loaded)
[916] 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 -r nvidia_drm nvidia_modeset nvidia_uvm nvidia']' 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 196, in _unload_modules
exec_bash("modprobe -r " + " ".join(modules_to_unload))
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 -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.
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 24, in setup_kernel_state
_nvidia_down(config)
File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 65, in _nvidia_down
_unload_nvidia_modules(available_modules)
File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 148, in _unload_nvidia_modules
_unload_modules(available_modules, ["nvidia_drm", "nvidia_modeset", "nvidia_uvm", "nvidia"])
File "/usr/lib/python3.8/site-packages/optimus_manager/kernel.py", line 198, in _unload_modules
raise KernelSetupError("Cannot unload modules %s : %s" % (str(modules_to_unload), str(e)))
optimus_manager.kernel.KernelSetupError: Cannot unload modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] : Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia' :
modprobe: FATAL: Module nvidia is in use.
[917] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[918] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20200621T142717', 'requested_mode': 'intel'}
In this second Intel session:
$ lsmod | grep -i nvid
nvidia 20520960 0
ipmi_msghandler 77824 2 ipmi_devintf,nvidia
$ sudo modprobe -r nvidia
$ lsmod | grep -i nvid
$ pacman -Qqs nvidia
egl-wayland
lib32-libvdpau
lib32-nvidia-utils
lib32-opencl-nvidia
libvdpau
nvidia-dkms
nvidia-utils
opencl-nvidia
SDDM Configs
/etc/sddm.conf.d/20-optimus-manager.conf
:
[X11]
DisplayCommand=/sbin/prime-offload
DisplayStopCommand=/sbin/prime-switch
/etc/sddm.conf.d/kde_settings.conf
:
[Autologin]
Relogin=false
Session=
User=andy
[General]
HaltCommand=/usr/bin/systemctl poweroff
Numlock=on
RebootCommand=/usr/bin/systemctl reboot
[Theme]
Current=breeze
CursorTheme=breeze_cursors
[Users]
MaximumUid=60000
MinimumUid=1000
[X11]
ServerArguments=-dpi 0
/etc/sddm.conf
:
[General]
InputMethod=
[Theme]
DisableAvatarsThreshold=7
EnableAvatars=true
FacesDir=/usr/share/sddm/faces
ThemeDir=/usr/share/sddm/themes
[Users]
DefaultPath=/bin:/usr/bin:/usr/local/bin
HideShells=
HideUsers=
RememberLastSession=true
RememberLastUser=true
ReuseSession=false
[Wayland]
EnableHiDPI=false
SessionCommand=/usr/share/sddm/scripts/wayland-session
SessionDir=/usr/share/wayland-sessions
SessionLogFile=.local/share/sddm/wayland-session.log
[X11]
# DisplayCommand=/usr/share/sddm/scripts/Xsetup
# DisplayStopCommand=/usr/share/sddm/scripts/Xstop
EnableHiDPI=false
MinimumVT=1
ServerPath=/usr/bin/X
SessionCommand=/usr/share/sddm/scripts/Xsession
SessionDir=/usr/share/xsessions
SessionLogFile=.local/share/sddm/xorg-session.log
UserAuthFile=.Xauthority
XauthPath=/usr/bin/xauth
XephyrPath=/usr/bin/Xephyr
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
TTY switch leads to FATAL error @ unloading nvidia modules
Whenever i switch to budgie with alt ctrl f7 while nvidia-xrun w/ openbox is ... will lead to modprobe: FATAL: Module nvidia_drm is...
Read more >Nvidia module failed to load, mint 20.1, kernel 5.4.0-65 - Linux
Hey Nvidia team, Nvidia kernel module is not loaded, which makes driver working in unknown mode and over-consumption of a battery.
Read more >NVIDIA/nvidia-drivers - Gentoo Wiki
This proprietary driver contains some wrapper functions that will compile against the Linux kernel and a binary blob that does the heavy lifting ......
Read more >How to unload kernel module 'nvidia-drm'?
I imagine you want to stop the display manager which is what I'd suspect would be using the Nvidia drivers. After change to...
Read more >Nvidia driver, CUDA tools and libraries - negativo17.org
Oh no, another Nvidia driver repository? Why? This repository reflects my personal view for the way the driver should be packaged for Fedora...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Late reply, but yeah, I know module unloading is wonky. It’s an issue that I can sporadically reproduce on my machine too. There must be some kind of race condition where the optimus-manager hook is called before X is done with the nvidia driver. It would explain why adding a simple
lsmod
is enough to hide the issue, since you’re basically adding a small delay before the module unloading.I’ll look into putting a synchronization point to loop over
modprobe -r
with a delay, and try a few times before giving up. It’s kind of a hack though, the proper way would be to check which programs are still hanging to the GPU, but I don’t know how to do that.Having the same problem, let me join the party. As an additional info, even after manually unloading nvidia module, it still refuses to switch to nvidia referring that there was a problem in last switching. Restarting the daemon and wait for some time (not sure how long, just for sure cannot be done immediately) allows the switching. Weird, eh?