Skip to main content
03.06.2026

nbd-vram for Linux Swap

head-image

Memory pressure on developer laptops and AI test boxes can be awkward. The machine may have an idle Nvidia GPU with gigabytes of VRAM, while the kernel spills pages to SSD swap. nbd-vram takes that unused GPU memory and exposes it as high-priority Linux swap.

The project reached the Hacker News front page with a practical pitch: use spare CUDA VRAM before falling back to slower or more wear-sensitive storage.

What Is nbd-vram?

nbd-vram is a small daemon that allocates Nvidia VRAM through the CUDA driver API, then serves it as a block device through Linux NBD. The kernel sees /dev/nbdX, formats it as swap, and can use it like any other swap target.

The data path is intentionally boring: Linux swap subsystem, NBD kernel driver, Unix socket, userspace daemon, CUDA copies, then GPU VRAM. That avoids a custom kernel module and avoids relying on Nvidia kernel symbols.

Key Features

  • Uses consumer Nvidia GPUs with CUDA support
  • Requires libcuda.so.1, but not the full CUDA toolkit
  • Exposes VRAM as normal Linux swap through /dev/nbdX
  • Backs off allocation in 512 MiB steps if the GPU is already using memory
  • Includes systemd integration, power-aware management, and smoke tests

For operators, the important point is scope. This is not a replacement for RAM. It is a buffer between real memory, zram, and SSD swap.

Installation

The README shows a simple install flow:

git clone https://github.com/c0dejedi/nbd-vram
cd nbd-vram
sudo ./install.sh
sudo systemctl start vram-swap-nbd

Verify that the swap device is active:

swapon --show
# NAME       TYPE      SIZE USED PRIO
# /dev/nbd0  partition   7G   0B 1500

Requirements include an Nvidia GPU with CUDA support, the Nvidia driver, Linux nbd support, nbd-client, gcc, and make.

Usage

Tune the amount of VRAM and swap priority in the systemd service:

Environment=VRAM_SETUP_SIZE_MB=7168
Environment=VRAM_SWAP_PRIORITY=1500

Then reload and restart:

sudo systemctl daemon-reload
sudo systemctl restart vram-swap-nbd

The project also includes test-nbd.sh for a 1 MiB write and readback smoke test, plus test-fill.sh for filling the full VRAM partition.

Operational Tips

Treat VRAM swap as a workstation and lab-host tool first. It makes the most sense on hybrid graphics laptops, idle desktop GPUs, and AI development machines where GPU memory is unused for long stretches.

Watch swap priority carefully. If VRAM swap sits above zram and SSD swap, it will absorb page pressure earlier. That can improve sporadic page-fault latency, but it can also compete with GPU workloads when someone starts a model, build, or graphics job.

Monitor nvidia-smi, swapon --show, service restarts, and battery state. The power-aware mode can stop the service when AC power is removed, which is useful for laptops but worth documenting for on-call engineers.

Conclusion

nbd-vram is a clever Linux memory pressure tool for systems with idle Nvidia VRAM. It will not make a small machine behave like a properly sized server, but it can reduce painful swap stalls on the right hosts.

If your team wants AI-assisted incident workflows with strong operational context, Akmatori helps SRE teams investigate alerts, coordinate response, and automate safe infrastructure actions. Powered by Gcore for global infrastructure reliability.

Automate incident response and prevent on-call burnout with AI-driven agents!