Article 6JKN4 Mounting video RAM on Linux

Mounting video RAM on Linux

by
BenCollver
from LinuxQuestions.org on (#6JKN4)
Title: Mounting video ram on Linux
Author: Soline
Date: 10 February 2024
Tags: linux
Description: In this article, you will learn how to store data in your
GPU memory on Linux

Introduction

Hi, did you ever wonder if you could use your GPU memory as a mount
point, like one does with tmpfs and RAM?

Well, there is a project named vramfs that allows you to do exactly
this on FUSE compatible operating system.

In this test, I used an NVIDIA GTX 1060 6GB in an external GPU case
connected with a thunderbolt cable to a Lenovo T470 laptop running
Gentoo.

ramfs official GitHub project page
<https://github.com/Overv/vramfs>

Setup

Install the dependencies, you need a C++ compiler and OpenCL headers
for C++ (the package name usually contains "clhpp").

Download the sources, either with git or using an archive.

Run `make` and you should obtain a binary in `bin/vramfs`.

Usage

It's pretty straightforward to use, as root, run `vramfs /mountpoint
3G` to mount a 3 GB storage on `/mountpoint`.

The program will stay in foreground, use Ctrl+C to unmount and stop the
mount point.

Speed test

I've been doing a simple speed test using `dd` to measure the write
speed compare to a tmpfs.

The vramfs mount point was able to achieve 971 MB/s, it was CPU bound
by the FUSE program because FUSE isn't very efficient compared to a
kernel module handling a file system.

Code: # env LC_ALL=C dd if=/dev/zero of=here.disk bs=64k count=30000
30000+0 records in
30000+0 records out
1966080000 bytes (2.0 GB, 1.8 GiB) copied, 2.02388 s, 971 MB/sMeanwhile, the good old tmpfs reached 3.2 GB/s without using much CPU,
this is a clear winner.

Code: # env LC_ALL=C dd if=/dev/zero of=here.disk bs=64k count=30000
30000+0 records in
30000+0 records out
1966080000 bytes (2.0 GB, 1.8 GiB) copied, 0.611312 s, 3.2 GB/sLimitations

I tried to use the vram mount point as a temporary directory for
portage (the Gentoo tool building packages), but it didn't work due to
an error. After this error, I had to umount and recreate the mount
point otherwise I was left with an irremovable directory. There are
bugs in vramfs, no doubts here :-)

Arch Linux wiki has a guide explaining how to use vramfs to store a
swap file, but it seems to be risky for the system stability.

ArchWiki: Swap on video
<https://wiki.archlinux.org/title/Swa...USE_filesystem>

Conclusion

It's pretty cool to know that on Linux you can do almost what you want,
even store data in your GPU memory.

However, I'm still trying to figure a real use case for vramfs except
that it's pretty cool and impressive. If you figure a useful
situation, please let me know.

From:
<gopher://dataswamp.org/1/~solene/art...-vram-on-linux>

Reminds me of VGADISK.SYS
<ftp://ftp.oldskool.org/pub/simtelnet...sk/vgadisk.zip>
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments