elementary / os

The OS build system
https://elementary.io
GNU General Public License v3.0
987 stars 131 forks source link

Poor battery life and high temperature on laptop with NVIDIA hybrid graphics #371

Open jhaygood86 opened 4 years ago

jhaygood86 commented 4 years ago

Prerequisites

Describe the bug

I use an Alienware m15 laptop that has NVIDIA Optimus. It should, in theory, prefer the Intel GPU and only use the NVIDIA GPU sparingly (video games, etc..). However, elementaryOS prefers the NVIDIA GPU which results in the laptop running hot and the battery life being non-existent.

To Reproduce

Steps to reproduce the behavior:

  1. Install elementaryOS
  2. Use laptop
  3. Notice laptop is oven and doesn't work on battery

Expected behavior

I expect the laptop to use the Intel graphics the vast majority of the time. I previously used Fedora on this laptop which did that and it worked beautifully, no overheating, battery life was many hours versus a few minutes. Some applications automatically opened on the NVIDIA card, others required selection in GNOME (GNOME 3.36 has new UI that is available that lets you run apps on NVIDIA card)

Platform Information

hanaral commented 4 years ago

Have you tried using the System76-power package from system76? It should be able to do this and also have custom profiles.

jhaygood86 commented 4 years ago

System76-power

I have not. However, like I said, it works out of the box on Fedora, so if it doesn't on elementary, I consider that an elementary bug.

elementary does support the hacky "nvidia prime" solution from Ubuntu that requires manually choosing the GPU and then rebooting (blegh, gross). Recent versions of GNOME however use a better integrated solution that elementary should adopt (or improve upon): GNOME is aware of the laptop having 2 different GPUs. By default, it prefers the integrated GPU. Apps that prefer the discrete GPU automatically run on them (using a flag in the .desktop file), and all apps have the option via a right click menu on the application. No rebooting required, and it actually allows most apps to use the Intel card and only a single specific app to use the NVIDIA card.. simultaneously.

hanaral commented 4 years ago

The prime driver switching isnt a part of GNOME I believe, since fedora has had it since before it was a part of the UI. I expect this is an issue with the fact that Hera is still based 18.04, hence why System76 created their own system that is portable across their LTS and current versions. That being said, you might want to open an issue asking for UX integration with prime with Odin in mind.

jhaygood86 commented 4 years ago

It is part of GNOME, using switcherooctl. This isn't using the "NVIDIA PRIME" solution that is considered obsolete these days since it requires rebooting. The GNOME implementation doesn't even require the system to be a NVIDIA Optimus system, it works with any system with both an integrated and a separate discrete card.

Lobosque commented 4 years ago

@jhaygood86 would you mind point me to na official gnome page documenting this solution? Thanks

jhaygood86 commented 4 years ago

Probably the easiest would be the GNOME Shell source code: https://gitlab.gnome.org/search?group_id=8&nav_source=navbar&page=2&project_id=546&repository_ref=master&scope=&search=discrete&search_code=true&snippets=false

Specifically, apply_discrete_gpu_env and shell_app_launch in shell-app.c, and then _updateDiscreteGpuAvailable and appDisplay.js

Essentially,

If both an integrated GPU and a discrete GPU is available (detected via switcherooctl dbus API), it displays a menu item for launching with a choice of either "run on Integrated" or "run on Discrete". The desktop file has a preference for whether or not that app should run on the integrated or discrete GPU which triggers that choice.

When the app is started, and its configured to run on the discrete (either due to it being the default choice, or specifically selected), it then uses switcherooctl to get the environment configuration needed to force an app to run on the discrete GPU, and then applies that environment prior to the app starting.

kem-a commented 3 years ago

So many things learned today. I always assumed that hybrid graphics management is baked into kernel, not depended of desktop you run. Also, I don't have 'switcherooctl' running on my system, its not even present.

I wish eOS had some elegant way of switching gpus without need for reboot.

jhaygood86 commented 3 years ago

So many things learned today. I always assumed that hybrid graphics management is baked into kernel, not depended of desktop you run. Also, I don't have 'switcherooctl' running on my system, its not even present.

I wish eOS had some elegant way of switching gpus without need for reboot.

eOS 6 will! I scratched my own itch and implemented it.

davidmhewitt commented 2 years ago

@jhaygood86 Can you add an update to this issue (or close it), with the current status of how this is on recent versions of elementary OS?