Search code examples
google-chromeelectrongpuchromium

How to limit Chromium GPU process system memory usage?


I'm developing an Electron app and I'm trying to figure out if there's a way (a flag?) that lets you limit gpu-process system memory usage

enter image description here

The gpu-process usually takes 500+ MB on content rich pages.

I'd like to force it to a lower value or programmatically force the app to use high-performance (discrete) GPU, which would move the cache from system memory to GPU memory.

Tried

I tried running the app with all of the gpu related flags found on this website but nothing worked:

  • Disabling hardware acceleration completely solves the problem but then the app renders at ~20 FPS at most, which renders this solution useless.
  • Specifying this flag doesn't help --gpu-program-cache-size-kb=1000
  • Disabling video GPU decoding with --disable-accelerated-video-decode reduces gpu-process memory a little bit but increases CPU usage
  • Running the app with these flags doesn't change anything either --enable-gpu-memory-buffer-compositor-resources --enable-gpu-rasterization --ignore-gpu-blocklist --enable-zero-copy
  • Running the app with the GPU#1 IDs specified in chrome://gpu doesn't active GPU#1 either: --gpu-vendor-id=0x10da --gpu-device-id=0x1c8a
  • Manually making the app to use discrete Nvidia GPU (in Nvidia graphics control panel) offloads the gpu-process system memory to GPU built-in memory, but I don't know how to programmatically force it to use discrete GPU instead of the integrated one.
  • (Electron specific) This flag --force_high_performance_gpu doesn't seem to do anything on Windows.

Solution

  • Hybrid graphics (NVIDIA Optimus, AMD Switchable graphics) is one of the early-state technology (in usability terms) even though it was introduced a long time ago.

    Technically the same applies to video cards in general. They were not supposed to be controlled by every application. Only specific software (Operation systems, Drivers, some games, and graphic tools) was responsible to manage them.

    These days everything is changing. Machine Learning and other basic tasks could be done on GPU relatively easily. And we even have some public tools for that. But still, it's hard and non-standardized.

    There were many attempts to control GPU in different software. You already tried many flags. And most of them are outdated already. There was even a moment when Chrom(ium) and Firefox were banned in Nvidia's drivers. i.e. There was no legit way to use them together.

    Windows took control over GPUs a long time ago. So neither drivers nor applications are responsible for the decision of what hardware will be used. And chromium does not seem to care much about this control anymore. They can't even fix the white screen problem with hardware acceleration.

    Linux distributives have a worse position. Drivers are not even fully functional. Canonical with NVidia made NVidia Prime to control hybrid graphics. And there are many other non-official solutions for that.

    I just want to say that it's better to avoid attempts to control GPU until it's super critical. The situation could be changed many times.

    Nevertheless, the best approach would be to register your application in Windows for higher performance before your application is started. I'm not aware if Windows provide a special tool except GUI for that. But you always can try to register the application through the Regedit in the path: Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\DirectX\UserGpuPreferences.

    Or you can rename your application executable to something famous so Windows will prioritize it without extra settings. e.g. chrome.exe -> doomx64.exe.