1

I have a laptop with a GeForce GT 650M. I recently installed Kubuntu 20.04 and have nvidia-prime installed.

I can select PRIME Profiles in nvidia-settings and I have "NVIDIA (Performance)", "NVIDIA On-Demand", and Intel (Power Saving Mode)".

When I select Intel, I suspect my NVIDIA card is still active because the laptop seems warmer than it should be and battery life is pretty bad.

In Kubuntu 18.04 I was able to use bbswitch to turn off the NVIDIA card. However, that doesn't work now. I get an error when I try modprobe.

$ sudo modprobe bbswitch
modprobe: ERROR: could not insert 'bbswitch': No such device

And indeed, dmesg shows:

[12360.793484] bbswitch: version 0.8
[12360.793498] bbswitch: Found integrated VGA device 0000:00:02.0: \_SB_.PCI0.GFX0
[12360.793509] bbswitch: No discrete VGA device found

And from lspci:

$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

It only shows the Intel card here.

So it looks like my GPU simply does not exist.

However, if I change the PRIME profile to any of the NVIDIA ones, lspci does show the NVIDIA GPU and glxinfo and friends show the NVIDIA card being used. So it does work!

So my question is, does Kubuntu 20.04 do something to drop the GPU from the PCI bus to power it down (and failing to power it down)?

Ultimately, I would like to power it down completely (there is no option in the BIOS). I have tried to go the bbswitch way, but if there are other ways, that would work too.

  • Just a side note, lspci | grep VGA does not show your card because VGA is not a string related to your card. I bet you see it with lspci | grep 3D and both with lspci | grep -i '3D\|VGA' – dadexix86 May 23 at 16:40
  • Ah, I did not know that. However, NVIDIA card shows up as 01:00.0 VGA compatible controller: NVIDIA Corporation GK107M [GeForce GT 650M] (rev a1) for me when in the "NVIDIA (Performance)" profile but not in the "Intel" profile. – DeathByDenim May 23 at 20:07
1

Ok, I found a way of turning off the NVIDIA card without using bbswitch. I still don't know why the NVIDIA card disappears from lspci when I use the Intel profile instead of any of the NVIDIA profiles.

The Arch wiki was very helpful here. I used the info there to write a script that turns off the NVIDIA GPU when I'm using the Intel card using ACPI calls.

First, install the ACPI call module.

$ sudo apt install acpi-call-dkms

Then edit "/etc/modules-load.d/modules.conf" and append acpi_call at the end. This will load the module on boot and activate "/proc/acpi/call".

The next step is to find the ACPI call required for the GPU. The acpi-call-dkms package comes with an example script that does just that. Run it to find the code where it say "It works".

$ sudo /usr/share/doc/acpi-call-dkms/examples/turn_off_gpu.sh

In my case, it shows "\_SB.PCI0.PEG0.PEGP._OFF" for my NVIDIA GeForce GT 650M.

Then I wrote a script to turn off the GPU, but only if the PRIME profile "Intel" is active. For the other profiles, the script does nothing and keeps the NVIDIA GPU active. This lets me still use the NVIDIA GPU as normal through prime-select. I saved the script as "/usr/bin/turn_off_gpu.sh".

#!/bin/bash

# Change this to whatever /usr/share/doc/acpi-call-dkms/examples/turn_off_gpu.sh tells you
ACPI_CODE="\_SB.PCI0.PEG0.PEGP._OFF"

GPU_IN_USE=$(prime-select query)

if [[ $GPU_IN_USE == "intel" ]]; then
  echo $ACPI_CODE > /proc/acpi/call
  result=$(cat /proc/acpi/call | tr '\0' '\n')
  case "$result" in
    Error*)
      echo "Failed to turn off discrete GPU. Possible wrong ACPI_CODE?"
      exit 1
      ;;
    *)
      echo "GPU has been turned off"
      exit 0
      ;;
    esac
fi

echo "Discrete GPU is in use, keeping it on"
exit 0

Note that this script needs to be run as root.

Finally, I want to run this script at boot so I created a systemd file for it at "/etc/systemd/system/gpuoff.service":

[Unit]
Description=Turn off GPU if using Intel

[Service]
Type=oneshot
ExecStart=/usr/bin/turn_off_gpu.sh

[Install]
WantedBy=multi-user.target

And enable this

$ sudo systemctl enable gpuoff

Now reboot and your GPU will be off when using the Intel PRIME profile and on when using any of the other profiles.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.