Setting gaming laptop to performance mode while running on battery


I’m trying to get the maximum performance of my laptop while running on battery (without power cord connected).

  • My laptop is: GIGABYTE AORUS 17 YE5
  • GPU: GeForce RTX 3080 Ti
  • Nvidia driver: 510.85.02
  • Ubuntu 20.04
  • kernel: 5.15.0-41-generic

I already tried the following solutions:
solution1: Set Nvidia GPU Performance Level possible? - Graphics & Display - Manjaro Linux Forum
solution2: create config /etc/modprobe.d/nvidia.conf and add
options nvidia NVreg_RegistryDwords="OverrideMaxPerf=0x1" to it.

In both solutions, the mentioned files wasn’t exist and I had to create them myself. but for both solution there wasn’t any improving of the GPU performance when I run the laptop on battery. I check the performance levels in the PowerMizer information tab in Nvidia X server setting, and it reaches maximum level of 2 when on battery, while on power it reaches the level 4 (highest level).

Do you know how/where I can configure the nvidia driver to always use the highest performance mode even without connecting to power?

Thanks in Advance,

AFAIK, that’s not possible without patching the driver.

Is there already a source code patch available or even a patched driver? and if not do you know how to patch it?

The driver’s module sources in kernel/nvidia/nv-acpi.c contain the function nv_acpi_get_powersource
I suspect modifying it to always report AC plugged should have the desired effect.
I don’t know if there are already patches available but I don’t think so.

Ok, I’ve set it to always true (AC plugged), Is there a way to safely build and install it ?

I guess you should modify the dkms sources in /usr/src/nvidia-(version)
Then do a
sudo dkms remove nvidia/(version)
sudo dkms install nvidia/(version)
to compile and install so it survives a kernel upgrade and you don’t have to mess with missing package dependencies.
Maybe also use apt hold to nail the specific version.