TL;DR

Researchers have developed a way to use Nvidia GPU VRAM as swap space on Linux systems. This approach enables hybrid laptop users to expand memory capacity by repurposing idle VRAM, with minimal setup and compatibility across CUDA-supported GPUs. Performance varies based on workload type, with high throughput favoring SSD or NVMe swaps, but low-latency tasks benefit from GPU VRAM.

Linux users with Nvidia GPUs can now use VRAM as swap space thanks to a new open-source daemon that leverages CUDA and NBD protocols, expanding system memory without kernel modifications. This development is particularly relevant for hybrid laptops with soldered VRAM and no upgrade options, enabling better performance under memory pressure.

The solution involves a small daemon that allocates VRAM via the CUDA driver API and exposes it as a block device using the NBD protocol. This device then functions as a swap space, integrated into the Linux swap subsystem. Tested on an AMD/ATI + RTX 3070 laptop with 16 GB RAM and 8 GB VRAM, the setup can allocate up to 7 GB of VRAM for swap, effectively tripling total addressable memory when combined with zram and SSD swap.

The approach bypasses limitations of the NVIDIA P2P API, which returns errors on consumer GPUs, and avoids complex kernel module modifications. Instead, it relies on CUDA memory copy operations (cuMemcpyHtoD/DtoH), which work across all CUDA-compatible GPUs, simplifying setup and maintenance. The daemon runs as a systemd service, automatically starting on boot and supporting power-aware management to optimize battery life.

Why It Matters

This development matters because it offers a cost-effective way to extend system memory on laptops with limited or soldered VRAM, potentially improving performance under heavy memory load. It also demonstrates a novel use of GPU VRAM beyond graphics rendering, opening avenues for hardware resource optimization and custom Linux configurations. However, performance differences mean this solution is best suited for low-latency or sporadic workloads rather than sustained high-throughput tasks.

ASUS ROG Astral NVIDIA GeForce RTX™ 5080 16GB GDDR7 White OC Edition - Quad-Fan Gaming Graphics Card Delivering unprecedented Airflow and air Pressure for Optimal Performance, 3 Year Warranty

ASUS ROG Astral NVIDIA GeForce RTX™ 5080 16GB GDDR7 White OC Edition – Quad-Fan Gaming Graphics Card Delivering unprecedented Airflow and air Pressure for Optimal Performance, 3 Year Warranty

AI Performance: 1899 AI TOPS.

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Traditional swap space on Linux relies on SSDs or NVMe drives, which can be slower than RAM but provide additional capacity. Hybrid laptops often have soldered VRAM, making upgrades impossible, and existing solutions like zram or SSD swap have limitations. Previous attempts to directly access GPU memory via the NVIDIA P2P API failed on consumer GPUs due to driver restrictions, prompting the development of this workaround. The method leverages CUDA’s ability to copy memory to and from the GPU, combined with a user-space daemon that presents VRAM as a block device over NBD.

“This approach sidesteps the limitations of the NVIDIA P2P API by using CUDA memory copy operations, which are universally supported across CUDA GPUs.”

— Developer of the nbd-vram project

“Using VRAM as swap has significantly increased my system’s responsiveness under heavy load, especially when multitasking.”

— Linux user and early tester

maxsun GeForce GT 730 2GB Video Graphics Card GPU for Computer PC GDDR3 PCI Express DVI-I, HDMI, VGA 4K Multi Screen

maxsun GeForce GT 730 2GB Video Graphics Card GPU for Computer PC GDDR3 PCI Express DVI-I, HDMI, VGA 4K Multi Screen

Powered by NVIDIA GeForce GT 730 GPU.

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It remains unclear how well this approach scales with different GPU models, workloads, or in long-term use. Compatibility issues may arise with certain driver versions or hardware configurations. Performance metrics vary depending on workload type, and the impact on GPU lifespan or thermal management is not yet fully understood. Additionally, ongoing kernel updates could affect the stability or functionality of the daemon.

SIX NVME M.2 SSD PCIe 4.0-1TB m.2 2280 ssd, Read UP to 7350MB/s 1TB for Gaming PS5 Memory Storage Expansion with Heatsink, Internal Solid State Hard Drive PCIe gen 4x4 Nvme for Laptop Desktop pc

SIX NVME M.2 SSD PCIe 4.0-1TB m.2 2280 ssd, Read UP to 7350MB/s 1TB for Gaming PS5 Memory Storage Expansion with Heatsink, Internal Solid State Hard Drive PCIe gen 4×4 Nvme for Laptop Desktop pc

Unleash Upgraded power – Employing PCIe Gen4x4 High Speed Interface, SIX X7400 nvme m.2 ssd confer it UP…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Further testing across diverse hardware setups is expected, alongside potential integration into mainstream Linux distributions. Developers may refine the daemon for better performance and stability, and users will likely explore customization options. Monitoring updates to CUDA drivers and Linux kernel support will be essential to maintain compatibility and optimize performance.

NVIDIA GeForce RTX 3060 Ti Founders Edition 8GB GDDR6 PCI Express 4.0 Graphics Card (Renewed)

NVIDIA GeForce RTX 3060 Ti Founders Edition 8GB GDDR6 PCI Express 4.0 Graphics Card (Renewed)

8GB GDDR6 256-bit Memory

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

Can I use this method on any Nvidia GPU?

Yes, the method works on any CUDA-capable Nvidia GPU, including consumer RTX and GTX cards, as long as the driver supports libcuda.so.1.

Does using VRAM as swap affect GPU lifespan?

While not yet fully studied, constant use of VRAM for swap could increase thermal and wear stress on the GPU. Users should monitor temperatures and system stability.

How does performance compare to traditional SSD swap?

VRAM swap offers lower latency for sporadic access but lower throughput for large sequential transfers compared to SSDs or NVMe drives. It is best suited for low-latency tasks rather than sustained high-throughput workloads.

Is this solution stable for daily use?

Early testers report stability, but long-term reliability is still being evaluated. Users should back up data and test thoroughly before relying on it for critical tasks.

How do I set up and configure VRAM swap on my Linux system?

Installation involves cloning the nbd-vram repository, running the install script, and configuring systemd service files. Detailed instructions are provided in the project’s documentation.

Source: Hacker News

You May Also Like

What’s the most expensive property sold in RI? May 30 real estate transactions

A Bristol property on Minturn Farm Road sold for $5.5 million on May 30, making it the most expensive sale in Rhode Island this week.

One Video In, a Whole Publishing Kit Out — Without the Cloud

Discover how to turn one video into a complete publishing kit offline. Save time, protect privacy, and control your content without relying on the cloud.

The United Kingdom: The Pragmatist’s Hedge

Thorsten Meyer AI’s Atlas frames the UK as a middle-course case on welfare, AI rules and work, with Universal Credit at its core.

Wall St slips as inflation worries push yields higher

US stocks fell on Friday amid rising inflation fears, which pushed bond yields higher, signaling investor concern over economic stability.