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

TL;DR

Linux users with Nvidia GPUs can now convert VRAM into swap space using a user-space daemon that leverages CUDA APIs. This approach enhances total addressable memory, especially for hybrid graphics laptops, without kernel module changes. Performance varies depending on workload type.

Linux users with Nvidia GPUs can now utilize their GPU’s VRAM as swap space through a user-space daemon that communicates directly with the CUDA driver API, bypassing kernel module limitations. This development provides a way to significantly increase available memory on hybrid graphics laptops without kernel modifications, which is particularly relevant for systems with soldered, non-upgradable memory.

The method involves a small daemon that allocates VRAM via the CUDA driver API and exposes it as a block device using the NBD (Network Block Device) protocol over a Unix socket. This device is then used as swap space by the Linux kernel. The approach avoids kernel module dependencies and does not require NVIDIA kernel symbols, making it resilient to driver updates. Tested on an AMD/ATI + RTX 3070 laptop with 16 GB RAM and 8 GB VRAM, the setup allocates up to 7 GB of VRAM as swap, effectively tripling total addressable memory when combined with zram and SSD swap. Benchmarks indicate that VRAM-based swap offers lower latency for sporadic, small I/O operations but slower throughput for large sequential transfers compared to NVMe SSDs.

Why It Matters

This development matters because it offers a practical solution for extending system memory on laptops with soldered VRAM, which cannot be upgraded. It enables more demanding applications and multitasking without hardware changes. Additionally, it sidesteps longstanding issues with NVIDIA’s peer-to-peer API restrictions and kernel module dependencies, simplifying implementation and maintenance.

NVIDIA GeForce RTX 3090 Founders Edition Graphics Card (Renewed)

NVIDIA GeForce RTX 3090 Founders Edition Graphics Card (Renewed)

Item Package Dimension – 15.0L x 12.25W x 4.25H inches

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Prior to this, using GPU memory as swap was limited by NVIDIA driver restrictions and the complexity of direct memory pinning. Existing approaches like nvidia_p2p_get_pages_persistent API often failed on consumer GPUs, returning errors or being gated behind Quadro/datacenter SKUs. The new method leverages CUDA’s memory copy APIs, which are available across consumer GPUs, and implements a user-space daemon to expose VRAM as a block device, effectively creating a high-priority swap device without kernel modifications.

“This approach allows Linux to use Nvidia VRAM as swap without kernel module dependencies or driver modifications, surviving driver updates seamlessly.”

— Developer of the nbd-vram project

“Allocating 7 GB of VRAM as swap tripled the total addressable memory, improving multitasking and application performance.”

— User testing on a laptop with RTX 3070

acer GPU Support Bracket, GPU Stand with Magnet Non-Slip Base,(L, 70-120mm)

acer GPU Support Bracket, GPU Stand with Magnet Non-Slip Base,(L, 70-120mm)

[Esports-grade Materials] Constructed from high-quality aluminum alloy, the acer GPU support bracket features an anodized finish that ensures…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It remains unclear how this approach performs under sustained high load or in different hardware configurations. Compatibility with all Nvidia consumer GPUs and across various Linux distributions has not been exhaustively tested. Additionally, the long-term stability and potential side effects on GPU operation and power management are still being evaluated.

Amazon

CUDA API GPU memory management

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

Further testing across different Nvidia GPU models and Linux distributions is expected. Developers may optimize the daemon for better performance and lower latency. Future updates might include more user-friendly configuration tools and integration with system management utilities. The community will likely explore extending this approach to other GPU brands or integrating it into mainstream Linux distributions.

Linux Kernel Programming: Developing kernel architecture and device drivers for character, block, USB, and network interfaces (English Edition)

Linux Kernel Programming: Developing kernel architecture and device drivers for character, block, USB, and network interfaces (English Edition)

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

Can I use this method on all Nvidia GPUs?

It works on consumer CUDA-enabled Nvidia GPUs, including RTX and GTX series. Compatibility with older or specialized GPUs has not been fully confirmed.

Does this impact GPU performance or stability?

Initial tests show it does not interfere with normal GPU operation. However, long-term effects and stability under heavy workloads are still being studied.

Is this method safe for my hardware?

Using the CUDA APIs as described is generally safe, but as with any experimental feature, there is a risk of instability. Users should test carefully and back up critical data.

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

Installation involves cloning the GitHub repository, running the provided install script, and configuring systemd services. Detailed instructions are included in the project’s documentation.

Source: Hacker News

You May Also Like

Tencent and Alibaba sales disappoint as AI monetization efforts fall short

Tencent and Alibaba reported weaker-than-expected sales for Q1 2026, citing slow AI monetization despite ongoing investments in artificial intelligence.

Scrcpy v4.0

Scrcpy v4.0 introduces SDL3 support, flexible display, camera torch and zoom controls, aspect ratio locking, and improved disconnection handling.

Apple backs Google after EU orders Android be opened up to AI rivals

Apple backs Google’s stance against EU proposals to open Android to rival AI services, citing privacy and security concerns amid regulatory scrutiny.

The gigawatt gap. Why China is structurally positioned for AI power and the US is engineering around its grid.

China is positioned for AI dominance due to its energy infrastructure, while the US faces a gigawatt gap impacting AI development. Here’s what we know.