Best Configuration for Intel UHD Graphics + Nvidia GPU and Battery Optimised

I am old to Linux, but I have never been able to understand what is the best way to use my dual GPU.
Previously I used to only use Noveau driver, then switched to Nvidia driver for my project works. And i dont know at what point, but my battery started degraded to 45%.
Currently im using EOS+Plasma and managing the GPU using optimus manager(Nvidia enabled with BBswitch).
Im exploring options to use my dual gpu to the best efficiency possible. I dont play any games on linux, but use gpu for ML/AI tasks very rarely. My utmost aim is to

  • Configure the gpu to not affect battery health and possibly giving leeway to use nvidia gpu performance when rarely needed.
  • Remove unrelated components which i installed past few weeks, which is stopping me from using softwares like OBS listed below:

For Output setting: nvenc,h.264

an encode error occured while recording 

For Output setting: nvenc,hevc

Failed to open NVENC codec: Generic error in an external library
Try installing the latest [NVIDIA driver](https://obsproject.com/go/nvidia-drivers) and closing other recording software that might be using NVENC such as NVIDIA ShadowPlay or Windows Game DVR.

Details:
inxi -Faz | eos-sendlog

https://0x0.st/Hhm6.txt

Have you seen these articles:

I think bbswitch is not the optimal way for your system, instead I’d look for the other options described in the links above.

Looked into them.
I have decided to stay with optimus manager,but change to noveau(considering its light and I can change drivers easily using nvidia-inst).

But why optimus manager not turning on and cant see GPU encoder options in OBS. Why is this so, isn’t my nvidia GPU still in use?

You can see what drivers/modules are in use with commands

lspci -vnn | grep -PA13 'VGA|3D|Display' | sed -E -n '/VGA|3D|Display/,/^$/p'
lsmod | grep -P 'nvidia|nouveau|i915'

Not sure but maybe nouveau is not supported by optimus manager?

1 Like

Tried all this, and still the OBS only shows software encoder(which uses CPU)

lspci -vnn | grep -PA13 'VGA|3D|Display' | sed -E -n '/VGA|3D|Display/,/^$/p'

00:02.0 VGA compatible controller [0300]: Intel Corporation CometLake-H GT2 [UHD Graphics] [8086:9bc4] (rev 05) (prog-if 00 [VGA controller])
        Subsystem: Acer Incorporated [ALI] CometLake-H GT2 [UHD Graphics] [1025:142f]
        Flags: bus master, fast devsel, latency 0, IRQ 148
        Memory at 6012000000 (64-bit, non-prefetchable) [size=16M]
        Memory at 4000000000 (64-bit, prefetchable) [size=256M]
        I/O ports at 5000 [size=64]
        Expansion ROM at 000c0000 [virtual] [disabled] [size=128K]
        Capabilities: <access denied>
        Kernel driver in use: i915
        Kernel modules: i915

01:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU117M [GeForce GTX 1650 Mobile / Max-Q] [10de:1f99] (rev a1) (prog-if 00 [VGA controller])
        Subsystem: Acer Incorporated [ALI] TU117M [GeForce GTX 1650 Mobile / Max-Q] [1025:142f]
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at a0000000 (32-bit, non-prefetchable) [size=16M]
        Memory at 6000000000 (64-bit, prefetchable) [size=256M]
        Memory at 6010000000 (64-bit, prefetchable) [size=32M]
        I/O ports at 4000 [disabled] [size=128]
        Expansion ROM at a1080000 [disabled] [size=512K]
        Capabilities: <access denied>
        Kernel modules: nouveau

lsmod | grep -P 'nvidia|nouveau|i915'

i915                 4169728  48
drm_buddy              20480  1 i915
i2c_algo_bit           20480  1 i915
ttm                   110592  1 i915
drm_display_helper    229376  1 i915
cec                    86016  2 drm_display_helper,i915
intel_gtt              28672  1 i915
video                  77824  2 acer_wmi,i915

ls /lib/modules/$(uname -r)/kernel/drivers/gpu/drm/nouveau/

nouveau.ko.zst

sudo modprobe nouveau
lsmod | grep -P 'nvidia|nouveau|i915'

nouveau              3665920  0
drm_gpuvm              28672  1 nouveau
mxm_wmi                12288  1 nouveau
drm_exec               12288  1 nouveau
gpu_sched              65536  1 nouveau
drm_ttm_helper         12288  1 nouveau
i915                 4169728  48
drm_buddy              20480  1 i915
i2c_algo_bit           20480  2 i915,nouveau
ttm                   110592  3 drm_ttm_helper,i915,nouveau
drm_display_helper    229376  2 i915,nouveau
cec                    86016  2 drm_display_helper,i915
intel_gtt              28672  1 i915
video                  77824  3 acer_wmi,i915,nouveau
wmi                    45056  6 video,intel_wmi_thunderbolt,acer_wmi,wmi_bmof,mxm_wmi,nouveau

Before modprobe you had no module in use for the Nvidia GPU. Is there a blacklist for nouveau somewhere?

There is no blacklist for nouveau that I could find(some commands worked listed below). Morever, noveau wasn’t loaded again(likely due to restart) and had to manually load it again.

sudo find /etc -type f -exec grep -l "nouveau" {} +

/etc/tlp.conf
/etc/eos-apps-info/pageinfo/nvidia-inst/nvidia-inst.html
/etc/ld.so.cache

ls /etc/modprobe.d

broadcom-wl.conf  firewalld-sysctls.conf

ls /etc/modules-load.d

gnutls.conf

Can you show the output of

pacman -Qs xf86-video

You seem to be using wayland. What happens if you use x11?

Here’s some more reading: https://wiki.archlinux.org/title/NVIDIA_Optimus

Neither nouveau nor Wayland are supported by Optimus Manager. the only “Switching” mode I have found that works under Wayland is Prime - Render Offload. This is what I am currently using on my Optimus Laptop.

Arch Wiki on PRIME Render Off Load

The rest of the solutions require that you run X11.

Your card is an NV160 (Turing) card and the Nouveau Driver will not give you the full performance.

Something to note, even if you are running on the Intel iGPU, the nvidia card is still drawing power. There are ways to shut it off, but they can cause instability. (I know this from experience.)

1 Like

Thanks!

And nvidia-inst has option --prime.

1 Like

@manuel

If the OP wants to use Prime under Wayland, they should take a look that this post I made in the Plasma 6 Update some hints thread.

In it, I give the proper environment values needed to run Prime.

Also, many of the switching options are no longer maintained, or have not been updated in a long time.

1 Like

So u suggest me to use X11 with Nvidia Driver(Hybrid mode) in Optimus manager? Is that right ?

will have a look at it

Not sure about X11, using wayland because it is new technology and future(from what I heard).

pacman -Qs xf86-video

local/xf86-video-nouveau 1.0.17-2 (xorg-drivers)
    Open Source 3D acceleration driver for nVidia cards
local/xf86-video-qxl 0.1.6-1 (xorg-drivers)
    Xorg X11 qxl video driver

Iam giving these configuration a try.

A doubt with the last step:
this is my current line in grub:
GRUB_CMDLINE_LINUX_DEFAULT='nowatchdog nvme_load=YES resume=UUID=153881bd-c338-41d0-b10c-8d4769b039c1 nvidia-drm.modeset=1 loglevel=3'
you want me to change the whole like to this?
GRUB_CMDLINE_LINUX_DEFAULT= nvidia-drm.modeset=1

Also for this conf, is there any cli commands to do the switching or should i install optimus-manager-qt?

No, just add it your existing line right after loglevel=3

Optimus Manager, as I said before, does not work on Wayland. If you want to use it, you have to use X11.

I have shifted to Envy Control, looks simple and easy to work with.

1 Like

So i have followed your configuration and using EnvyControl to use Hybrid Mode(still using wayland).
After that sometimes , I’m getting some glitches like the image below like

  • glitches in panel
  • glitches in application
  • Hover effect not working as intended on panel(like showing the preview,etc)

image

What could be the reason?

I do not know. I use Prime. Also, from reading the information about Envy Control, it is for X11 only. Not Wayland.

1 Like

any quick tip on how to shift from wayland to X11, seamlessly?