Linux 7.3 improves performance when running out of vRAM

pixelcluster.dev

469 points by flaburgan 13 hours ago


bsimpson - 11 minutes ago

I have a Z1 Extreme that has 16GB shared between the CPU and GPU (what AMD calls the APU). I've noticed that mangohud, the SteamOS utility that shows performance diagnostics, often reports RAM + VRAM numbers that exceed 16GB. I've been curious as to why. I presume it has to do with compression or something.

krisknez - 10 hours ago

I hope there will be an update where when my RAM gets full my PC doesn't freeze and becomes unusable... I remember that Linux and Windows do this in different ways and Windows doesn't have the problem.

exceptione - 11 hours ago

Great article! I share the same hunch as the author does; when allocating memory ultimately the application itself is in the best position to inform the kernel about the desired stickiness to VRAM. The best a kernel can do is guessing.

As a side note, it strikes me how much we owe to young trans people for low level performance engineering.

d3Xt3r - 11 hours ago

Gosh, 7.2 literally just dropped with a bunch of awesome of performance/gaming related improvements (large folios, cache-aware scheduling, improved MGLRU reclaiming, Fair GPU Scheduler etc)... and I already can't wait for 7.3 to come out.

Meanwhile in the Windows world, users hate updates... Like I genuinely can't think of a single instance that made users exclaim, "oh boy I just can't wait for the next Patch Tuesday!".

Lunar5227 - 12 hours ago

Well written and very informative. I am glad we have these enthusiastic people around for Linux kernel development!

inventor7777 - 6 hours ago

I see all the comments about how Windows and Linux handle OOM, but I suppose I'll also mention macOS.

On my M4 Max Mac Studio if I try to load too big of an AI model with protections off, the desktop starts glitching back and forth between the past few hundred frames. It looks bad when it happens but CtrlC still works to kill llama.cpp and if you were using LM Studio, SSH also works. Once you kill the offending process, or if macOS does it for you, the desktop comes back immediately.

hypfer - 12 hours ago

I'll be the one to ask the obvious question:

What does this mean for compute workloads? Specifically, LLM inference.

Does it mean anything at all, or is this purely a games-thing?

nickjj - 10 hours ago

This post focuses on performance, but what about crashing due to apps seeing no RAM available to allocate once VRAM is filled up?

I remember having this problem when I used an NVIDIA 750 Ti with 2 GB of memory. Just opening a few Firefox or Ghostty terminals (both are GPU accelerated) would result in those apps crashing or not being able to render their contents. Sometimes the compositor would crash or become unstable too (kwin, niri, etc.). I had to reboot every few hours. Complete system instability.

This problem only happened with Wayland, when I switched to X windows these problems went away.

Since then I switched to an AMD RX 480 (8 GB) GPU and never had an issue here with Wayland, if GPU memory gets full, system memory gets seamlessly used instead. It felt like with the NVIDIA card, it never allocated back to system memory if no VRAM was available. This was only a problem on Linux since that same NVIDIA card was fine in Windows for 10+ years with zero issues related to instability around VRAM allocation.

Tons of people reported the same issue on Linux on NVIDIA's forums for years.

I wrote a lot more details and recorded demo videos around 9 months ago here https://nickjanetakis.com/blog/gpu-memory-allocation-bugs-wi..., but since then a lot of these things have been resolved from switching over to AMD.

dormento - 7 hours ago

A curious thing happens in my Ubuntu 24 system, maybe that's just the normal OoM killer algo but no matter what process is hogging, Firefox is killed. Chrome eating too much memory? Firefox dies. Too many apps open? Firefox dies. Its funny.

kjuulh - 11 hours ago

Great article. I find that I learn something every time I read a post about linux kernel work.

I guess an LRU with priority would handle VRAM for games pretty decently without going getting too application specific.

What about VRAM to Disk specifically NVME, would direct to disk be feasible for large workloads, I know it is used for streaming in assets directly via. PCIE, but i wonder how the performance would be on compute workloads running with NVME as a swap for GPU VRAM.

Beijinger - 7 hours ago

You know what I would like to have? An application that sends a kill / kill -9 signal to a specific app, example Chromes, when things go south.

skew-aberration - 12 hours ago

Great writeup, gpuvis looks particularly interesting and glad the kernel is providing tracepoints for performance events.

> Not only does the display hardware like scanned-out images to be in VRAM, it also completely skips past the GPU’s virtual memory architecture and works with physical addresses exclusively.

Well there's your problem. Only so smart your memory management can be when you have to pay the cost of doing it manually. Although presumably this only applies to a small fraction of the VRAM?

Prunkton - 10 hours ago

Such great work! Happens quiet regularly I hit a game just realizing seconds later I haven't shut down my local LLM yet. At least punishment will be less harsh. Lets see, maybe some games in window mode will just work fine.

londons_explore - 10 hours ago

I'm mostly excited for the VRAM savings from apps and games which have loads of unused or super rarely used textures.

Game developers often aren't super careful with this stuff, and there could be literal gigabytes of data which isn't used at all.

imfemambocus - 12 hours ago

This is a nice blog and it makes sense to me now. As a gamer and linux user myself, I've previously had to do tweaks and go-arounds without really understanding what was going on behind the scenes. :)

pranav_tech26 - 8 hours ago

Honestly, swap thrashing on low vRAM setups has been painful forever. Glad to see Linux kernel optimizations targeting memory pressure where it actually hurts.

HelloUsername - 10 hours ago

Also Apple M3 support

fencer12 - 4 hours ago

More Linux goodies

- 9 hours ago
[deleted]
hnc3yfnu6f - 8 hours ago

Wish more people understood this

j16sdiz - 8 hours ago

It's VRAM, not vRAM.

pranav_tech26 - 12 hours ago

[dead]

bansiwebix - 9 hours ago

[dead]