optimus-manager: Optimus manager crashes when system upgrades to python 3.9

After system upgrade, on Arch optimus manager crashes, so any GUI is not working. I needed to reinstall optimus-manager to get it working again. Its becouse Arch upgraded to python 3.9 and optimus manager doesnt know it, and looks at 3.8 libraries.

Im sharing this becouse there can by other issues with this problem, when only whots needed is reintall. Maybe push a update to avoid that? Also journalctl -xe, or dmesg didnt show anything related to this. a bit strange. But the status of services says the problem.

journalctl -u optimus-manager -xe:

gru 02 21:38:27 ArchSzybet python3[855]: /usr/bin/python3: Error while finding module specification for 'optimus_manager.hooks.post_da> gru 02 21:38:27 ArchSzybet systemd[1]: optimus-manager.service: Control process exited, code=exited, status=1/FAILURE ░░ Subject: Proces jednostki zakończył działanie ░░ Defined-By: systemd ░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel ░░ ░░ Proces ExecStopPost= należący do jednostki optimus-manager.service zakończył działanie. ░░ ░░ Kod wyjścia procesu: „exited”, jego stan wyjścia: 1.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 30 (8 by maintainers)

Most upvoted comments

Please rebuild the package from the AUR. It will then use Python 3.9 instead of Python 3.8. I faced this same error, and rebuilding the package fixed it.

Credits: LIN_X42’s comment on the AUR page for optimus-manager.

I had to chroot into my system, disable lightdm, and update the system to be able to get xorg working properly. Once I could log into a graphical session, I reinstalled optimus manager, cleaned up stale system config files (optimus-manager --clean) and then enabled lightdm again. This worked for me.

This seems to affect all AUR packages that depend on the AUR. I wrote a little script to update all of these pacakges (not just optimus-manager). This way you don’t have to rebuild a bunch of AUR packages that don’t need to be rebuilt:

#!/bin/bash
# Find the AUR packages that require python and rebuild them

aur=$(pacman -Qqm | sort);
req=$(pactree -rl -d 1 "python" | sort);
yay -S --rebuild $(comm -12 <(echo "$aur") <(echo "$req"));

I might write a hook to do this automatically, I’ll comment here again if that works out

Thx for getting back.

yay -R optimus-manager; yay -S optimus-manager does not actually rebuild the package. It uninstalls it and reinstalls the old package from your pacman cache.

I think yay has a --rebuild flag or something similar though. Not really sure what it exactly is, because I’m not a yay user. Might also be --cleanbuild, check the docs.

I used yay -R optimus-manager followed by yay -S optimus-manager, when installing I chose to recompile everything from source, which yay does by removing the cached version and by reinstalling.

Now my computer seems to be in Intel mode. I can read the GPU temperature sensor but nvidia-settings is not working.

This is the log of optimus manager (which is similar to the one posted above):

[27] INFO: # Xorg pre-start hook
[27] INFO: Previous state was: {'type': 'pending_pre_xorg_start', 'requested_mode': 'integrated', 'current_mode': None}
[27] INFO: Requested mode is: integrated
[905] INFO: Available modules: ['nouveau', 'bbswitch', 'acpi_call', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
[947] INFO: No processes currently holding the Nvidia GPU
[947] INFO: Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] (if loaded)
[950] ERROR: Xorg pre-start setup error
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/optimus_manager/bash.py", line 11, in exec_bash
    out = subprocess.check_output(
  File "/usr/lib/python3.9/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 524, 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.9/site-packages/optimus_manager/kernel.py", line 255, in _unload_modules
    exec_bash("modprobe -r " + " ".join(modules_to_unload))
  File "/usr/lib/python3.9/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.9/site-packages/optimus_manager/hooks/pre_xorg_start.py", line 51, in main
    setup_kernel_state(config, prev_state, requested_mode)
  File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 25, in setup_kernel_state
    _nvidia_down(config)
  File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 101, in _nvidia_down
    _unload_nvidia_modules(available_modules)
  File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 207, in _unload_nvidia_modules
    _unload_modules(available_modules, ["nvidia_drm", "nvidia_modeset", "nvidia_uvm", "nvidia"])
  File "/usr/lib/python3.9/site-packages/optimus_manager/kernel.py", line 257, 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.

[951] INFO: Removing /etc/X11/xorg.conf.d/10-optimus-manager.conf (if present)
[951] INFO: Writing state {'type': 'pre_xorg_start_failed', 'switch_id': '20210104T174910', 'requested_mode': 'integrated'}

This log makes no sense as there are no processes holding the GPU and I have manually and successfully ran: > sudo modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia

To be honest, I’d like to know how to help with this because this tool is incredibly helpful to me and I thank the developer for all the work!

found this after 2hours of debugging. I was suspecting Xorg for no GUI or diplay after update but it was Optimus. Automatic rebuild or some other fixes will be appreciated.

It took me a few days to figure out why updating (a whole bunch of stuff including) python broke my entire system. It would be pretty cool if this didn’t happen in the future.