Live data from Hacker News

Use your Nvidia GPU's VRAM as swap space on Linux

github.com

111–120 of 142 posts

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#111
post #110

Building a swap device at user level used to be one of those classic unsolvable problems, because what if your daemon needs to swap in a page in order to swap in a page? Or at least it was discussed at a reason why microkernels will never work. I’m not sure what the solution is here.

The general principle is that what is involved in paging should not be paged itself. Wiring the memory of that whole daemon is then a trivial solution to the problem.

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#112

RAM disks have always fascinated me. In a different timeline every PC has a 100gb of RAM and 50TB HDDs are the norm.

Having 128 GB in my desktop, I can never, ever go back. It truly unlocks a whole different computing experience. I've only had one OOM in the last 5 years and it was in my own code where I had a bad memory leak. It's the only way to live

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#113

Why does my Apple Sillicon Mac with 32gb of RAM use (or even create?!) a swapfile, when 20gb is still unused/"free"? Why can I not just enter a simple command to entirely-disable swapfile, like with Linux's: >>>>swapoff -a Seems kind of silly, unless the point is intentionally to wear-down the SSD's lifespan . Having a GUI swapfile-disable system preference would be awesome. It would also be awesome if Apple finally…

The principle of a paging system is that main memory is just a cache for secondary memory, and the concept of "free memory" ideally rather means something like "memory that can be quickly reclaimed for another purpose". Sometimes anonymous memory will be of less us occupying main memory at some given time than would be letting cached file contents take their place.

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#114
post #110

Building a swap device at user level used to be one of those classic unsolvable problems, because what if your daemon needs to swap in a page in order to swap in a page? Or at least it was discussed at a reason why microkernels will never work. I’m not sure what the solution is here.

Your daemon can be smart enough to know which are its own pages and prevent them from being swapped out. The Linux kernel also prevents its own text pages from being swapped out, so the solution exists and I don’t see why it doesn’t apply to microkernel designs.

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#116

Earlier quoted context omitted.

I mean, if you aren’t using the car while using the boat and it won’t really damage the car… yes?

And when you use your car, then what?

Then it doesn’t function as a boat anchor anymore. The point is that only a few people are using their GPU at any time.

The bandwidth is terrible here, but if it wasn’t, this would be a good utilization of resources.

Re: Use your Nvidia GPU's VRAM as swap space on Linux

#118

Earlier quoted context omitted.

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 ;)

Wouldn't this prevent the nvidia GPU from being power gated since it's never "idle"? So like your battery life regresses?

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

#119

Earlier quoted context omitted.

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.

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.

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

#120
post #27

Remember how 16GBs used to be an enterprise level database mainframe? Well, GPUs also have stupid amounts of compute on them. I have to imagine that there is some kind of database format that's useful with GPU compute attached. Since the data is already in VRAM, the GPU can sort, join, or otherwise manipulate data as needed.

GPU-accelerated databases have a long history. I founded HeavyAI (previously MapD/OmniSci) in 2013, but there are or have been many other startups in this space, such as Voltron Data, Kinetica, Sqream, etc. And now you have major players like IBM, Starburst, and Microsoft (which just announced Fabric SQL on GPU today) working on their own GPU-accelerated systems. GPUs have a huge advantage in terms of compute, memory…

And smart NICs are moving significant amounts of compute directly onto the network interface, though I haven't seen anyone combining a GPU and a 100GbE NIC into a single part yet.

Where does a few more steps of evolution take us? A wide path between a few heavy devices, and then the CPU off to the side just orchestrating the data flow?

Post reply on HN