Askannz / optimus-manager

A Linux program to handle GPU switching on Optimus laptops.
MIT License
2.27k stars 165 forks source link

Fail to unload nvidia (in use by nvidia_uvm) #170

Closed YoyPa closed 4 years ago

YoyPa commented 4 years ago

Describe the bug When trying to switch from nvidia to intel, it fail to unload nvidia module because it's in use by nvidia_uvm and according to gpu_setup.log it doesn't try to unload nvidia_uvm first.

System info Please include :

Logs

Optimus Manager (Setup script) version 1.2.2
Setting up the GPU
Checking status of optimus-manager.service
Cleaning up leftover Xorg conf
Removed /etc/X11/xorg.conf.d/10-optimus-manager.conf
Loading config
Requested mode : intel
Checking for GDM display servers
Available kernel modules : ['nouveau', 'bbswitch', 'acpi_call', 'nvidia', 'nvidia_drm', 'nvidia_modeset']
Setting up base state
Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia'] (if loaded)
Cannot setup GPU : kernel setup error : Cannot unload modules ['nvidia_drm', 'nvidia_modeset', 'nvidia'] : Failed to execute 'modprobe -r nvidia_drm nvidia_modeset nvidia' : modprobe: FATAL: Module nvidia is in use.

Fix ? I looked into: https://github.com/Askannz/optimus-manager/blob/0f4fc3c07d3560c298abd3989a470eb097fb3eb7/optimus_manager/kernel.py#L130 And nvidia_uvm is not listed in _get_available_modules, wondering if it's normal. :innocent:

Askannz commented 4 years ago

Nope it's not, thanks for catching that. There's a blacklist installed though, so it's weird that the module is loaded in the first place.

https://github.com/Askannz/optimus-manager/issues/147 is likely the same issue.

Askannz commented 4 years ago

Would you mind testing the latest master ?

YoyPa commented 4 years ago

There's a blacklist installed though, so it's weird that the module is loaded in the first place.

nvidia_uvm is not loaded with the session but after some time, maybe some userspace program modprobe it O.O", and blacklist can't affect that.

YoyPa commented 4 years ago

I've found when nvidia_uvm is loaded, it's when I watch a video:

mpv --hwdec=auto --ytdl-format 'bestvideo[height<=1080]+bestaudio/best[height<=1080]' %u
(%u being the youtube url)
journalctl
oct. 29 13:01:49 yo-gs kernel: nvidia-uvm: Loaded the UVM driver, major device number 236.
lsmod | grep -i nvidia
nvidia_uvm           1097728  0
nvidia_drm             57344  16
nvidia_modeset       1114112  12 nvidia_drm
nvidia              19968000  1119 nvidia_uvm,nvidia_modeset
ipmi_msghandler        69632  2 ipmi_devintf,nvidia
drm_kms_helper        217088  2 nvidia_drm,i915
drm                   520192  17 drm_kms_helper,nvidia_drm,i915

I've tested the latest kernel.py, nvidia_uvm and nvidia are unloaded correctly. :+1:

log

2019-10-29 01:05:51 PM +0100 ==================== 

Optimus Manager (Setup script) version 1.2.2
Setting up the GPU
Checking status of optimus-manager.service
Cleaning up leftover Xorg conf
Removed /etc/X11/xorg.conf.d/10-optimus-manager.conf
Loading config
Requested mode : intel
Checking for GDM display servers
Available kernel modules : ['nouveau', 'bbswitch', 'acpi_call', 'nvidia', 'nvidia_drm', 'nvidia_modeset', 'nvidia_uvm']
Setting up base state
Unloading modules ['nvidia_drm', 'nvidia_modeset', 'nvidia_uvm', 'nvidia'] (if loaded)
Unloading modules ['nouveau'] (if loaded)
Loading module bbswitch
Setting GPU power to ON via bbswitch
Loading module bbswitch
Setting up Intel state
Setting GPU power to OFF via bbswitch
Loaded extra Intel Xorg options (0 lines)
Loaded extra Nvidia Xorg options (0 lines)
Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
Askannz commented 4 years ago

Alright, thanks for testing.