Disabling compositing to save video memory in Linux
05.08.2020 [Software]
If you're using software that is taxing on video memory like Blender, it's very likely that you'll run into some error saying "Insufficient video memory" sooner or later. The most obvious thing to do then is to reduce the scene complexity, use smaller textures or pre-bake objects. However, there is also another great way to make more of your precious video memory available. And that is by disabling compositing.

Composited desktops have been around for many years, beginning with MacOS in the early 2000's, followed by Linux with Compiz and then Windows Vista in 2006. While it certainly is - let's call it - interesting, I've never really seen a real advantage for me.

Traditionally you simply had one framebuffer and all applications directly drew into that.
Compositing then added a step in between, by giving each application it's own framebuffer and then putting everything together (hence the term compositing) in the "real" framebuffer that's displayed. This allows for effects like window previews, blurred windows and other window effects, but all of this is usually done on the video card and eats up the more memory the more windows you have open.

If you have an NVIDIA card and use the proprietary driver, you can see the used video memory in the "NVIDIA X Server Settings" after selecting your GPU (look for "Used Dedicated Memory").

I highlighted the row with the used memory in red

Disabling compositing can easily save you hundreds of megabytes, but depending on your desktop environment (DE) it's not always easy to disable compositing unfortunately. If you're running vanilla Ubuntu with Unity or GNOME Shell for example, there is no way to disable it since it's an essential part of it. The only way is to switch to a different DE like KDE or XFCE. The same goes for Cinnamon and Budgie. I for my part switched to XFCE and I'm really happy with it now after I created my own light theme. If you are unsure if you can disable compositing with your DE, just do a quick search in the internet.

The actual way to disable compositing varies depending on your DE and configuration, but you can usually find it in the window manager settings or advanced window manager settings.

I create architectural renders as a hobby and thanks to this I was able to render images that I otherwise would have had to buy a new video card with more memory for. So I hope that this tip is useful to you if you run into the same problem and that it saves you some trouble when using CUDA with Blender.