Ubuntu 20.04 executing 2x gnome-shell processes with Nvidia driver


I noticed that Ubuntu 20.04 uses almost 400MB more RAM when using Nvidia drivers than with Intel’s drivers and also, looking at the active process, that there are 2 gnome-shell processes running along when using Nvidia’s driver, which not happens with Intel. One of these processes is owned by my user, and the other by gdm. Is it supposed to be like this, or it’s bug?

Finally, according to nvidia-smi output, Xorg only runs on the Nvidia’s GPU when i select “On Demand” option on PRIME. When i select “Performance” mode, nothing runs on the GPUs by default. Thinking a little bit about it, it kinda makes sense if Performance is thought to run a unique process (like a game) alone. But it is strange that “On Demand” runs Xorg by default, and not on Demand, as the name suggests.

How does it works? I’m really not criticizing, just trying to figure it out.
For instance, games will always run on Nvidia’s GPU selecting “Perfomance” and not on “On Demand”?


The following pictures was taken to prove my points:

  1. Intel (Power Saving Mode)
  2. Nvidia (On Demand)
  3. Nvidia (Performance Mode)


It is really difficult to extract good metrics on memory utilization in Linux.
The process count is not a good indicator.

When GNOME Shell starts, it spawns many /usr/bin/gnome-shell processes to handle tasks of the graphics environment. Each spawned process does not take up multiple times the memory of the initial process. There is a well-known optimization that most of the memory is shared, and you only count the private memory in each new process. If you were to really add the MBs shown in the output of top, you would get more MBs than what your physical memory.

As far as I know, those multiple /usr/bin/gnome-shell processes are there to anticipate your use of the desktop environment. There might be heuristics that spawn a set number of processes depending on your GPU driver. In other words, you would need to look for special tools that measure the memory use in more detail.

Not sure if there is a question here.
Certainly on optimus machines when using the performance profile rendering is done thru the nvidia adapter, display is always thru Intel (on most optimus machines.
With the on-demand profile the nvidia adapter is only used when specifically ‘told’ to. I gather this can be done via an env or command, or with gnome-shell thru the context menu option to use dedicated …
To what advantage there is with that context menu option to open an app is debatable, would depend on the app. For most normal apps there isn’t any.
I don’t have any games, that would be an area to see how it works.

As far as media/video players only mpv can take full advantage of this, i.e using nvdec or for some vdpau for decoding if set up for vdpau in mpv.conf.
Vlc and others cannot. Whether the vlc gui window is rendered by nvidia is off no value, I’ve no idea how to tell anyway…

Ok, but why nvidia-smi doesn’t show anything on Performance mode? It seems that Gnome isn’t being rendered by nvidia. Does it happen with you too?

About the 2x gnome-shell processes, it’s still hard for me to think it’s normal. Right now the gdm’s gnome-shell is using 500MB, while FF is only using 432, and the other gnome-shell is using 307. I’m using almost 2.9GB only with 1 tab opened on FF and one Htop.

My point here is to try to understand if this behavior is normal or it’s a bug. But based on your answers, i begin to believe that it’s normal.

Your smi screenshot for performance is quite suspect, 0 MiB is totally unexpected and indicative of a possible local issue. You should be logging in at 100+ MiB, going up with usage.
You should troubleshoot that somewhere, this place isn’t for such activity.
You also should have the 2 process’s as shown in the on-demand screen.

As far as process shown, it doesn’t show for individual things like file manager, terminal, text editor, ect. Though you’d see the memory use go up with use under the xorg line.
Some app processes will show up individually , certainly video players and similar.

The memory used is better indicator, run smi like this, gets updated every 2 sec.
watch nvidia-smi
screen shows smi on one laptop that supports process’s, my othere older don’t…

That’s the result i expected to see in my system! I’ll do some more research and open a bug somewhere to troubleshoot this.
Thank you for the answers!

Ps.: I just found out that the package nvidia-dkms-440 wasn’t installed. Probably because i must had installed nvidia-driver-440 from the terminal, and the dkms is not a dependency of it. After installing it the smi command is showing the right stuff now. It shows 2x Xorgs and 1x Gnome-Shell.

I still not sure why 2x Xorgs are running on GPU and 2x Gnome-shell processes, but i think 2 is better than nothing. haahah

The nvidia-driver-440 went version number backward just before focal release for some reason.
Initially I believe it was flawed and didn’t install nvidia-dkms-440 or something like that.
Was fixed shortly thereafter…

Just for info because you asked about the on-demand profile. In addition to the context menu option one can implement from the cli which could be more useful.
To test any app from cli there are several commands, 2 are -
__NV_PRIME_RENDER_OFFLOAD=1 app blah,blah

So for ex. with mpv that has nvdec support
__NV_PRIME_RENDER_OFFLOAD=1 mpv --hwdec=auto /path/to/file


1 Like

I’ve been away a while but noticed some confusion here so let me add a few comments:

I noticed that Ubuntu 20.04 uses almost 400MB more RAM when using Nvidia drivers than with Intel’s drivers

The Nvidia driver has always done that. Same goes for CPU usage too. Nvidia just uses more of everything compared to Intel.

there are 2 gnome-shell processes running along when using Nvidia’s driver

That sounds like a minor bug. The one running as ‘gdm’ is meant to terminate after you log in. I suggest logging a bug upstream about that.

Multiple processes

They are not multiple processes, they are multiple threads of the same process. Linux is a little weird compared to other Unixes in that it makes threads the top-level visible entity so simple tools might find it hard to recognise they are all the same process. But as a user you can generally tell by the fact that they all have the same memory stats.

1 Like

Thanks for the answer!

I kinda knew that, but i’d never seen that much difference. However, after installing nvidia-dkms pkg, the memory usage is way less (~1.3GB) , just as the difference when using Intel (~200MB). I didn’t do any change in the system since then that could affect this, besides the normal updates. That’s the kind of memory usage that i was expecting.

Ok. I definitely will