jarcode-foss / glava

GLava - OpenGL audio spectrum visualizer
GNU General Public License v3.0
1.17k stars 58 forks source link

Performance issues on laptop with hybrid graphics with the NVIDIA driver #165

Open UtkarshKunwar opened 4 years ago

UtkarshKunwar commented 4 years ago

I was struggling with this issue of exorbitant GPU memory usage by Xorg on my Kubuntu 18.04 until someone told me to try killing Glava (which showed only about 20MB GPU memory usage). My laptop temperatures were really high, the fans were constantly on at full speed, and my DE was lagging like crazy. And indeed after killing Glava, Xorg started behaving normally and my GPU memory usage dropped from 3.7GB/4GB to just a measly 479MB.

However, Glava runs just fine when I switch to the weaker intel graphics. No throttling or performance issues whatsover. This happens only when I switch to the higher perfomance NVIDIA graphics.

Here are the outputs from the nvidia-smi command with Glava running and after a couple of minutes of force-closing.

While running Glava:

Thu Jun  4 23:25:32 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M1200        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   67C    P0    N/A /  N/A |   3713MiB /  4043MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1974      G   /usr/lib/xorg/Xorg                          3365MiB |
|    0      2800      G   kwin_x11                                      49MiB |
|    0      2807      G   /usr/bin/krunner                               1MiB |
|    0      2809      G   /usr/bin/plasmashell                          78MiB |
|    0      2876      G   /usr/bin/latte-dock                           59MiB |
|    0      2966      G   /usr/bin/akonadi_archivemail_agent             1MiB |
|    0      2970      G   /usr/bin/akonadi_googlecalendar_resource       1MiB |
|    0      2976      G   /usr/bin/akonadi_imap_resource                 1MiB |
|    0      2980      G   /usr/bin/akonadi_imap_resource                 1MiB |
|    0      2989      G   /usr/bin/akonadi_mailfilter_agent              1MiB |
|    0      3010      G   /usr/bin/akonadi_sendlater_agent               1MiB |
|    0      3345      G   ...uest-channel-token=xxxxxxxxxxxxxxxxxxxx    15MiB |
|    0      8463      G   ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files    94MiB |
|    0     14723      G   glava                                         19MiB |
+-----------------------------------------------------------------------------+

After killing Glava:

Thu Jun  4 23:28:33 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M1200        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   43C    P0    N/A /  N/A |    479MiB /  4043MiB |      4%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1974      G   /usr/lib/xorg/Xorg                           159MiB |
|    0      2800      G   kwin_x11                                      48MiB |
|    0      2807      G   /usr/bin/krunner                               1MiB |
|    0      2809      G   /usr/bin/plasmashell                          78MiB |
|    0      2876      G   /usr/bin/latte-dock                           59MiB |
|    0      2966      G   /usr/bin/akonadi_archivemail_agent             1MiB |
|    0      2970      G   /usr/bin/akonadi_googlecalendar_resource       1MiB |
|    0      2976      G   /usr/bin/akonadi_imap_resource                 1MiB |
|    0      2980      G   /usr/bin/akonadi_imap_resource                 1MiB |
|    0      2989      G   /usr/bin/akonadi_mailfilter_agent              1MiB |
|    0      3010      G   /usr/bin/akonadi_sendlater_agent               1MiB |
|    0      3345      G   ...uest-channel-token=xxxxxxxxxxxxxxxxxxxx    15MiB |
|    0      8463      G   ...AAAAAAAAAAAACAAAAAAAAAA= --shared-files    87MiB |
+-----------------------------------------------------------------------------+
sersorrel commented 4 years ago

I have a similar problem, also with Nvidia graphics (proprietary drivers, version 450) on an Optimus laptop. I don't notice an immediate performance problem, but each instance of GLava I open causes Xorg to consume an additional ~500MB of VRAM.

epm0dev commented 4 years ago

I ran into this issue recently as well and just found a solution for it (hopefully).

inxi -F:

Graphics:  Device-1: Intel driver: i915 v: kernel 
           Device-2: NVIDIA GP107GLM [Quadro P1000 Mobile] driver: nvidia v: 440.59 
           Display: x11 server: X.Org 1.20.5 driver: modesetting,nvidia 
           unloaded: fbdev,nouveau,vesa resolution: 1920x1080~60Hz 
           OpenGL: renderer: Quadro P1000/PCIe/SSE2 v: 4.6.0 NVIDIA 440.59 

Before Fix

nvidia-smi before launch:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro P1000        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   57C    P0    N/A /  N/A |    193MiB /  4042MiB |      9%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1104      G   /usr/lib/xorg/Xorg                           126MiB |
|    0      1682      G   cinnamon                                      65MiB |
+-----------------------------------------------------------------------------+

FPS/UPS console output:

...
FPS: 15.71, UPS: 14.72
FPS: 15.61, UPS: 15.61
FPS: 15.45, UPS: 15.45
FPS: 15.55, UPS: 15.55
FPS: 15.73, UPS: 15.73
FPS: 15.55, UPS: 15.55
FPS: 15.47, UPS: 15.47
FPS: 15.52, UPS: 15.52
FPS: 15.51, UPS: 15.51
FPS: 15.54, UPS: 15.54
FPS: 15.47, UPS: 15.47
FPS: 15.70, UPS: 15.70
...

nvidia-smi after launch:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro P1000        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   61C    P0    N/A /  N/A |   3952MiB /  4042MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1104      G   /usr/lib/xorg/Xorg                          3844MiB |
|    0      1682      G   cinnamon                                      65MiB |
|    0      8004      G   glava                                         40MiB |
+-----------------------------------------------------------------------------+

The Fix

What worked for me was simply opening NVIDIA X Server Settings, navigating to XScreen 0 > Antialiasing Settings and fooling around with the settings there. There seems to be some sort of issue with having 'Use Application Settings' selected here for some reason. It seemed like most configurations worked well, aside from pumping AA up to 64x. I eventually settled on selecting 'Enhance Application Settings' and checking the box next to 'Enable FXAA'.

After Fix

FPS/UPS console output:

...
FPS: 112.58, UPS: 105.60
FPS: 112.30, UPS: 111.31
FPS: 112.74, UPS: 106.76
FPS: 109.42, UPS: 108.43
FPS: 112.33, UPS: 106.36
FPS: 111.84, UPS: 111.84
FPS: 109.00, UPS: 107.02
FPS: 111.21, UPS: 107.24
FPS: 112.75, UPS: 111.75
FPS: 110.90, UPS: 109.90
FPS: 113.58, UPS: 112.60
FPS: 113.19, UPS: 111.20
FPS: 112.75, UPS: 111.75
FPS: 113.62, UPS: 109.63
FPS: 111.94, UPS: 109.94
FPS: 111.95, UPS: 106.95
FPS: 109.85, UPS: 109.85
FPS: 113.31, UPS: 110.33
...

nvidia-smi output:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro P1000        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   71C    P0    N/A /  N/A |    281MiB /  4042MiB |    100%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1104      G   /usr/lib/xorg/Xorg                           168MiB |
|    0      1682      G   cinnamon                                      61MiB |
|    0      8435      G   glava                                         50MiB |
+-----------------------------------------------------------------------------+
UtkarshKunwar commented 4 years ago

@epmancini can confirm that this workaround works for me. But I still don't think it should require tinkering with the NVIDIA X Server Settings.

Edit: After saving the settings and logging out and logging back in, it's back to the same memory hogging (I have added glava in the autostart programs in KDE). I have to kill that instance and launch it again for it to work with this workaround. For now I have changed the command of glava in the program to sleep 10 && glava and it seems to be temporarily working.

ducaton commented 1 year ago

I found more compact solution. Thanks @epm0dev for a hint. Just execute and add this to autostart:

nvidia-settings -a "FSAAAppControlled=0"

More details: https://download.nvidia.com/XFree86/FreeBSD-x86_64/530.41.03/README/openglenvvariables.html