You are not logged in.

#1 2021-04-08 01:53:14

phollox
Member
Registered: 2013-05-04
Posts: 42

bbswitch not working because GPU driver is in use

Stupid question.

I have a laptop with an nVIDIA GPU and an Intel graphics. I want to turn off the GPU when not in use.
The current state of the system was discussed here:
https://bbs.archlinux.org/viewtopic.php?id=263633

I installed and enabled bbswitch. However, because the nvidia drivers are loaded and in use, bbswitch can't turn off the GPU

I'm loading the drivers for nvidia on KMS, as explained on the previous post. Is this affecting bbswitch?

I'm getting

~/ dmesg | grep bbswitch                             

[   99.862674] bbswitch: version 0.8
[   99.862685] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.GFX0
[   99.862696] bbswitch: Found discrete VGA device 0000:01:00.0: \_SB_.PCI0.PEG0.PEGP
[   99.862869] bbswitch: detected an Optimus _DSM function
[   99.862878] bbswitch: device 0000:01:00.0 is in use by driver 'nvidia', refusing OFF
[   99.862881] bbswitch: Succesfully loaded. Discrete card 0000:01:00.0 is on

For the previous output, I loaded bbswitch manually, with options

# modprobe bbswitch load_state=0 unload_state=1

That's why the timestamps are as high. But loadïng it during boot has the same result.

The dev says that I need to unload the video driver for the GPU. But then, how I'm going to use the GPU when bbswitch activates it?

My goal with the GPU is CUDA, not rendering

Thanks


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#2 2021-04-08 10:33:16

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 9,132

Re: bbswitch not working because GPU driver is in use

Try removing the nvidia modules from mkinitcpio , then rebooting.
Does bbswitch work now ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2021-04-08 21:40:44

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

Thanks,

I removed the nvidia modules from the MODULES array in mkinitcpio. Regenerated the images

# mkinitcpio -P

Changed the kernel line in /etc/default/grub to remove nvidia-drm.modeset=1. Updated grub

# grub-mkconfig -o /boot/grub/grub.cfg

And rebooted.

$ dmesg | grep bbswitch
[    2.005672] bbswitch: version 0.8
[    2.005677] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.GFX0
[    2.005682] bbswitch: Found discrete VGA device 0000:01:00.0: \_SB_.PCI0.PEG0.PEGP
[    2.005770] bbswitch: detected an Optimus _DSM function
[    2.005894] bbswitch: disabling discrete graphics
[    2.113148] bbswitch: Succesfully loaded. Discrete card 0000:01:00.0 is off

In short, it seems to works.

I still need to see if it turns back on when required by CUDA, or if I have to manually activate it writting ON into /proc/acpi/bbswitch

Thanks

EDIT:

# tee /proc/acpi/bbswitch <<< OFF
OFF

However

$ dmesg | grep bbswitch           
[    2.005672] bbswitch: version 0.8
[    2.005677] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.GFX0
[    2.005682] bbswitch: Found discrete VGA device 0000:01:00.0: \_SB_.PCI0.PEG0.PEGP
[    2.005770] bbswitch: detected an Optimus _DSM function
[    2.005894] bbswitch: disabling discrete graphics
[    2.113148] bbswitch: Succesfully loaded. Discrete card 0000:01:00.0 is off
[ 1849.328441] bbswitch: device 0000:01:00.0 is in use by driver 'nvidia', refusing OFF

So the GPU was active

$ dmesg | grep nvidia  
[    2.266592] nvidia-gpu 0000:01:00.3: can't change power state from D3cold to D0 (config space inaccessible)
[    2.266598] nvidia-gpu 0000:01:00.3: can't change power state from D3hot to D0 (config space inaccessible)
[    2.266777] nvidia-gpu 0000:01:00.3: pci_alloc_irq_vectors err -22
[    2.267193] nvidia-gpu: probe of 0000:01:00.3 failed with error -22
[    3.047663] nvidia: module license 'NVIDIA' taints kernel.
[    3.110059] nvidia-nvlink: Nvlink Core is being initialized, major device number 235
[    3.242656] nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[    3.393905] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  460.67  Thu Mar 11 00:03:18 UTC 2021
[    3.399246] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[    3.399247] [drm] Initialized nvidia-drm 0.0.0 20160202 for 0000:01:00.0 on minor 1
[ 1849.328441] bbswitch: device 0000:01:00.0 is in use by driver 'nvidia', refusing OFF

Thanks

Last edited by phollox (2021-04-08 22:31:36)


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#4 2021-04-09 10:50:28

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 9,132

Re: bbswitch not working because GPU driver is in use

Try creating /etc//etc/modprobe.d/bbswitch.conf & starting bbswitch on boot, [1] for details .

Another possible cause is https://github.com/Bumblebee-Project/bb … issues/140 .
Please post full dmesg & journalctl -b (run both as root)




[1] https://wiki.archlinux.org/index.php/Bu … g_bbswitch

Last edited by Lone_Wolf (2021-04-09 10:50:45)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
Did you use the guided installer ? If yes, I can't help you.

(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2021-04-12 07:56:38

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

AHHHHH

I've been trying to reply to your post and for some reason, the message is not submitted


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#6 2021-04-12 08:30:06

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

The universe is against this reply.

SEVEN TIMES I TRIED. Clogged toilets, Kitchen breakers, Soiled diapers. And the DAMN timeout of the server that logs me out before clicking REPLY


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#7 2021-04-12 08:32:54

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

Eight attempt

The bbswitch is already starting from /etc/modprobe.d/bbswitch.conf

$ cat /etc/modprobe.d/bbswitch.conf 
options bbswitch load_state=0 unload_state=1

Requested logs

# dmesg | ix
[url]http://ix.io/2VOb[/url]

# journatctl -b | ix
[url]http://ix.io/2VOg[/url]

I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#8 2021-04-12 08:41:26

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

That one is already posted. Now, some extras

The bbswitch is working, I believe. It manages to turn off the GPU. However, another nvidia module is loaded and activates the GPU. And it stays on. Unable to turn it off writing OFF into /proc/acpi/bbswitch.

I also saw the timestamps moving. Previous post report the "bbswitch: Succesfully loaded. Discrete card 0000:01:00.0 is off" after the 2 sec mark. In the last batch, it appears after the 4 sec. A recent update of acpi_call corrected this

There's also a bunch of ACPI errors. I have to check if they always been there.

Finally, I tried to blacklist some nvidia modules, and see how it changed. FULLY blacklist, with install instead of blacklist. I ended up with a machine that's no longer Optimus. Not very smart, but hey, bbswitch now works. Dopeler effect (stupid ideas seems smarter when they come at you quickly)

$ cat /etc/modprobe.d/bbswitch.conf 
install nvidia /bin/true
install nvidia-drm /bin/true
install nvidia-nvlink /bin/true
install nvidia-modeset /bin/true
options bbswitch load_state=0 unload_state=1

I'll try with regular blacklist. That way, I believe the kernel could turn on the GPU if CUDA requires it


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#9 2021-04-12 09:08:18

phollox
Member
Registered: 2013-05-04
Posts: 42

Re: bbswitch not working because GPU driver is in use

Blacklisting the modules worked. The GPU remains off after boot. And I can write to /proc/acpi/bbswitch to turn it ON and back OFF.

I'll see how if affects battery life. Not sure if CUDA could load the nvidia modules directly and enable the GPU

Funny how at the beginning I put all nvidia in the modules array for KMS, and I ended up blacklisting them.

The fact that I find that amusing speaks tons about my sense of humor. My wife must REALLY love me

Last edited by phollox (2021-04-12 09:11:15)


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

Board footer

Powered by FluxBB