News for hackers. Stuff that matters.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by yjftsjthsd-h on Tuesday June 02, 2026 @07:36PM (#48377699)
> Built for laptops with soldered memory and no upgrade path. If you have an RTX card sitting there with 8GB of VRAM and you're getting swapped to SSD, this puts that VRAM to work.

Well, that does at least answer my immediate question about why I would ever swap from expensive RAM to really expensive RAM:) Feels niche, but when you want it it's a good idea.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by Wowfunhappy on Tuesday June 02, 2026 @08:45PM (#48378222)
Another possible reason that occurred to me: what if you have VRAM but you're not using it all the time? For example, let's say you bought a GPU because you like to play video games. When you're not actively gaming, you probably don't need 16 GB of VRAM just to render the desktop. Might as well use it for something else, right?

Edit: Although, this is predicated on the system being able to release VRAM that is acting as swap when it's time to start a game. Can it do that?

Re:Use your Nvidia GPU's VRAM as swap space on Linux by Saris on Tuesday June 02, 2026 @09:38PM (#48378719)
It's easy enough to 'offline' swap space on Linux normally so I suspect that would work fine, as long as you didn't instantly run out of RAM when doing so.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by eru on Wednesday June 03, 2026 @12:30AM (#48379913)
If you have enough swap on disk available, it should be fine.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by c0dejedi on Wednesday June 03, 2026 @12:54AM (#48380057)
I am catching up on comments

The reason I wrote this is I run this laptop in hybrid (AMD display + NVIDIA as swap). So all at VRAM was going to waste.

On your question re: switchable swap. It's on my to-do list ;)

Re:Use your Nvidia GPU's VRAM as swap space on Linux by kllrnohj on Wednesday June 03, 2026 @09:38AM (#48383899)
Wouldn't this prevent the nvidia GPU from being power gated since it's never "idle"? So like your battery life regresses?
Re:Use your Nvidia GPU's VRAM as swap space on Linux by nyrikki on Wednesday June 03, 2026 @01:58PM (#48387392)
While it may prevent sleep, one of the frustrations I have on an old skylake desktop with a bunch of 1080ti GPUs is that when set to power saving modes, the GPUs sit at 1x2.0 pcie lanes and low wattage. That slows down loading quite a bit.

So it will use more power, but nothing close to when the GPU is being used.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by tremon on Wednesday June 03, 2026 @03:14PM (#48388498)
Is VRAM not directly accessible by the system then? Since it's mapped directly into the CPU's address space, I had assumed that there's a simple DMA controller managing said access and I would then also naively assume that said controller is separate (or at least on a separate power plane) from the actual GPU.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by kllrnohj on Wednesday June 03, 2026 @04:22PM (#48389439)
they are talking about the scenario of having a discreet GPU in addition to the GPU on the CPU. So there's 2 GPUs, and the nvidia one has its own VRAM (typically of the GDDR variety even) that isn't shared with system RAM (hence the purpose of this project). So that also means 2 memory controllers.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by qingcharles on Wednesday June 03, 2026 @04:04PM (#48389225)
Good point, you might wanna disable it on battery, but I'm guessing a lot of people have their laptop plugged in practically 24x7.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by nuccy on Wednesday June 03, 2026 @03:19AM (#48380948)
Best case is if gaming and productivity (with high memory use) activities are not concurrent, and productivity applications are stopped before gaming starts, then `swapoff` can easily release swap device without restart.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by ornornor on Wednesday June 03, 2026 @08:24AM (#48383051)
> you probably don't need 16 GB of VRAM just to render the desktop

Microsoft: hold my beer

Re:Use your Nvidia GPU's VRAM as swap space on Linux by p_l on Thursday June 04, 2026 @03:58AM (#48395564)
You mean Chrome? (Looking at the 5GiB usage here...)
Re:Use your Nvidia GPU's VRAM as swap space on Linux by Wowfunhappy on Friday June 05, 2026 @07:58AM (#48411208)
Google Chrome is using 5 GB of VRAM?! Are you running something with WebGPU or something?
Re:Use your Nvidia GPU's VRAM as swap space on Linux by p_l on Friday June 05, 2026 @09:14AM (#48412058)
It's called prerendering tabs or something :V

At 4k it adds up, especially since if you look into DevTools Chrome actually renders more at least vertically if not across major scroll regions.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by ErroneousBosh on Wednesday June 03, 2026 @03:18AM (#48380942)
In the olden days we called that a "RAM Disk" and it made our Atari STs go really fast!

On the old Amstrad PCWs that were everywhere at least in the UK in the mid 80s to mid 90s you could have up to 512kB of RAM, a fair chunk of which could be a RAM disk. This made compiling stuff in Turbo Pascal really fast too :-)

Re:Use your Nvidia GPU's VRAM as swap space on Linux by 3form on Wednesday June 03, 2026 @06:21AM (#48382131)
Except swap is, like, opposite of RAM disk.

That said, still an nice and fun concept. Though caching got better since I assume :)

Re:Use your Nvidia GPU's VRAM as swap space on Linux by lloeki on Wednesday June 03, 2026 @08:06AM (#48382904)
RAM disk is, like, the brd module on Linux, which allocates and exposes a /dev/ram0 block device.

From the project description this looks like it, exposing a raw block device backed by VRAM (with some trip through the nbd protocol, but that's an implementation detail to have it in userland, it could just as well have been implemented kernel side).

It's just that the usage of this mem-backed block device is different than the thing of yore (copy HD or floppy into RAM)

The more frequent alternative to brd, tmpfs, skips the block device part and does a filesystem directly. I wonder if it could be made so that it's swap directly and skip the block device part entirely like tmpfs.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by Phelinofist on Wednesday June 03, 2026 @03:38AM (#48381066)
So can VRAM actually be used like regular RAM? E.g. if I have a 16GB module and my GPU has 16GB VRAM, could it be made so that my system reports 32GB RAM? What would be the implications of that?
Re:Use your Nvidia GPU's VRAM as swap space on Linux by tobyhinloopen on Wednesday June 03, 2026 @03:49AM (#48381128)
It behaves like slower ram I assume, due to the increased distance from the CPU and overhead. Still, it’s much faster than normal SWAP which uses a disk or SSD.

How it is reported? As SWAP space, not as RAM.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by Tuna-Fish on Wednesday June 03, 2026 @03:47AM (#48381118)
Typical desktop GPU ram does not support being write-back cached by the CPU. With PCIe resizable BAR, you could map the area into ram, so you could technically fit 32GB to memory, but it would have to be uncached (or write-combine cached), which would make it really, really slow.

There are a bunch of datacenter GPUs that support full cache coherency, but if you used them like that the VRAM would be very high latency from the CPU. So it would only be really slow.

Re:Use your Nvidia GPU's VRAM as swap space on Linux by ChocolateGod on Wednesday June 03, 2026 @07:59AM (#48382848)
I assume on Linux you could use something like daxctl to tell the kernel to treat the vRAM as normal RAM, but I think this would be Intel/AMD only.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by Tuna-Fish on Wednesday June 03, 2026 @08:59AM (#48383411)
I don't think it would help. It's not just a software issue that can be fixed in the kernel, the hardware fundamentally isn't part of the cache coherency system of the CPU.
Re:Use your Nvidia GPU's VRAM as swap space on Linux by tiberious726 on Wednesday June 03, 2026 @02:18PM (#48387668)
This is correct, look at IBM's CAPI for an example of the needed hardware
Re:Use your Nvidia GPU's VRAM as swap space on Linux by namibj on Friday June 05, 2026 @10:32AM (#48413090)
Isn't the problem with write back cache mode just due to the GPU being unable to invalidate cache lines in the CPU?