Askannz / optimus-manager

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

nvidia mode not working, nvidia modules already in use #147

Open jazz-g opened 4 years ago

jazz-g commented 4 years ago

Can't switch to Nvidia. Startup is set to Nvidia, but loads Intel. There are no optimus-manager files in /etc/X11/xorg.conf.d/, or any files for that matter. Intel loads Plasma fine.

System info OS: Arch Linux x86_64 Host: HP Pavilion Gaming Laptop 15-dk0xxx Kernel: 5.3.1-arch1-1-ARCH DE: Plasma CPU: Intel i5-9300H (8) @ 4.100GHz GPU: Intel UHD Graphics 630 GPU: NVIDIA GeForce GTX 1050 3 GB Max-Q LM: SDDM Version: Optimus Manager 1.2.1 (latest stable)

Logs boot_setup.log gpu_setup.log prime_setup.log

ttsesm commented 4 years ago

same problem here, I had to downgrade to 1.2.0 to have it working again

wuzhican commented 4 years ago

how can i downgrade to 1.2.0. wuzhican@wuzhican-pc OS: Manjaro 18.1.0 Juhraya Kernel: x86_64 Linux 5.2.11-1-MANJARO Uptime: 20m Packages: 1292 Shell: bash Resolution: 1920x1080 DE: KDE 5.61.0 / Plasma 5.16.4 WM: KWin GTK Theme: Breath [GTK2/3] Icon Theme: maia Font: Noto Sans Regular Disk: 100G / 229G (47%) CPU: Intel Core i7-7700HQ @ 8x 3.8GHz [62.0°C] GPU: GeForce GTX 1050 RAM: 2152MiB / 11888MiB

ttsesm commented 4 years ago

@wuzhican for manjaro I guess you need to follow this https://wiki.manjaro.org/index.php?title=Downgrading_packages

install the downgrade package and then run sudo downgrade optimus-manager

Askannz commented 4 years ago

I'm really puzzled here. The error is caused by the nvidia modules being already loaded before optimus-manager can manage them. However, 1) they shouldn't be loaded at all because optimus-manager installs a blacklist 2) The code path up to this point is almost identical between v1.2 and v1.2.1.

@TheodoreT @wuzhican if you're still around, can you confirm the same error appears in your boot_setup.log with v1.2.1 ?

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.
ttsesm commented 4 years ago

@Askannz I confirm that I am getting the same error here.

Also forgot to mention in my initial post that I am also with archlinux, and the latest stable packages regarding both kernel and nvidia drivers.

Askannz commented 4 years ago

Is any nvidia module loaded if you boot into console mode with the kernel parameter systemd.unit=multi-user.target ?

ttsesm commented 4 years ago

@Askannz both with v1.2.1 and v1.2.0 the only module that shows up after booting in console mode and it is related to nvidia is the i2c_nvidia_gpu, nothing else.

By the way which xorg-server are you using? Are you using the patched version that supports prime offloading or the default one from the official repositories. Here I am using the default one if that makes any difference.

Sino-Huang commented 4 years ago

@Askannz Hi, I faced the same issue and then I solve it by adding 'sudo' command. I am not sure what happens here.

pedrovanzella commented 4 years ago

Running as root did not work for me

wuzhican commented 4 years ago

i'm facing the same problem. logs: [Uploading boot_setup.log…]() [Uploading gpu_setup.log…]() [Uploading prime_setup.log…]() Optimus Manager (Client) version 1.2.1 and i have modify the /etc/mkinitcpio.conf, after i delete the modules, it's still doesn't work

wuzhican commented 4 years ago

logs: boot_setup.log gpu_setup.log prime_setup.log

wuzhican commented 4 years ago

我似乎找到了问题所在, 我尝试运行了一下这些命令, sudo rmmod nvidia sudo rmmod nvidia-u 我忘了后面的两个字母,大概系统提示我要被引用的模块,我都rmmod了。 然后我尝试switch-mode 大概是成功了,至少日志里面没有异常。 logs: boot_setup.log gpu_setup.log prime_setup.log

参考这个链接

wuzhican commented 4 years ago

it's actually runing 2019-10-23_13-29

Sino-Huang commented 4 years ago

what is the use of rmmod btw? rmmod是删除module还是 重置module呀

wuzhican commented 4 years ago

不知道,google出来的,看那个参考链接

wuzhican commented 4 years ago

根据这几天的观察,我这边好像是因为invidia_uvm模块没有放在modprobe的移除列表里,然后由于依赖关系导致nvidia无法退出,在root用户下运行modprobe -r nvidia_uvm 后就正常了。

wuzhican commented 4 years ago

according to my experience,it's because the nvidia_uvm is activing.so the nvidia module cannot be remove.after i run 'modprobe -r nvidia_uvm' as root .the optimous_manager run normal for me.

ttsesm commented 4 years ago

FYI with the latest version (i.e. v1.2.2) and after the last update on the kernel and the nvidia driver since yesterday switching from intel to nvidia works without issues again. I guess at the end the issue could have been because the nvidia guys were messing around as usual :-1: .

Askannz commented 4 years ago

I've also pushed a fix for https://github.com/Askannz/optimus-manager/issues/170, which may also have been the cause of the current issue.

Please test the latest master (optimus-manager-git), and let me know if it solves the issue.

pedrovanzella commented 4 years ago

I can confirm it's working with the latest commit

ttsesm commented 4 years ago

@Askannz I am still getting problems. The way I can replicate the problem is the following:

If I check which nvidia modules are still active I can see that nvidia_uvm and nvidia are still there. Thus, if I remove them manually with rmmod nvidia_uvm nvidia and then try to switch to nvidia mode then it works again.

The gpu_setup.log gives me the following output:

(switching from working nvidia to intel)

2019-11-16 03:36:24 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']
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.

(switching from intel to nvidia, not working since nvidia modules were not unloaded successfully)

2019-11-16 03:37:07 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
Loading config
Requested mode : nvidia
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.

(after manually removing remaining nvidia modules, switching back to nvidia from intel work again)

2019-11-16 03:37:47 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
Loading config
Requested mode : nvidia
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)
Unloading modules ['nouveau'] (if loaded)
Loading module bbswitch
Setting GPU power to ON via bbswitch
Loading module bbswitch
Setting up Nvidia state
Loading module nvidia
Loading module nvidia_drm
Loaded extra Intel Xorg options (0 lines)
Loaded extra Nvidia Xorg options (8 lines)
Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
cosmicdan commented 3 years ago

Exact same issue as @ttsesm above, except I can't just manually remove module and repeat - optimus-manager refuses to continue because of the previous error when leaving Intel.

While in this "Intel working fine, my dynamic GPU<>VFIO binding for VM working fine but cant switch to nvidia a second time" situation is:

I'd like to minimize this stuff where possible. Do note I'm new to using multiple GPU's and xorg config in general so I apologize for not recording any relevant logging, but I've a strong hunch it's to do with multiple monitor outputs and/or prime render, or at least my particular setup of that. Once during my experimentation (e.g. restarting the om service, manually unloading modules, etc) - I logged out of KDE normally and back in and I was randomly in hybrid mode, according to the QT tray indicator. This was coming from the above "stuck in intel mode" scenario, after switching into intel from nvidia.

Also, I believe this only started happening once I had a nice setup in KDE to disable the Intel HDMI output while under NVIDIA (which is using DP). Note I did that under KDE Display Config - NOT via xrandr scripts or xorg - because I thought it least intrusive (doesn't apply until after login) but maybe I've introduced a race condition.

I do boot to Nvidia by default on startup, but changing that to Intel didn't help; the same problem remained - switching from nvidia to intel is a one-way trip (without some manual stuff or a full restart).

I'll post a reply if I manage to fix my situation neatly, but I'd be interested to know what everyone else's setup is in regards to monitors/multihead and whether they're using Plasma or another DE to manage monitors (vs xrandr or xorg) too.