Stupid Graphics Card Question: card memory general purpose? - Page 1
Forum section: electronics / general

author: westfw
author_rank: Super Contributor
timestamp: October 22, 2020, 12:26:21 am
content: Stupid question:If your desktop has a graphics card with, say, 4GB of memory, but you're currently not doing anything GPU-intensive, can/will the CPU/OS use that as general purpose memory? Granted that the PCIe bus isn't as fast as the actual memory bus, it's still much faster than disk-like storage...

author: Siwastaja
author_rank: Super Contributor
timestamp: October 23, 2020, 08:24:32 am
content: No, this is not being done.It's an interesting idea, though.

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 23, 2020, 08:57:30 am
content: not directly i guess, you need to go through DirectX/OpenGL API and do some hack from there. but for what? when you can RAM up your MB at not so much price.

author: Jeroen3
author_rank: Super Contributor
timestamp: October 23, 2020, 09:02:01 am
content: If you have so much unused vram you could put swap there.https://github.com/prsyahmi/GpuRamDrive

author: magic
author_rank: Super Contributor
timestamp: October 23, 2020, 09:10:25 am
content: Actually, part/all of the VRAM is mapped into the CPU address space and can be accessed like any other physical RAM. Same applies to many other PCI devices.Throughput and access latency is going to be worse than primary RAM.The CPU will typically be configured not to cache this memory; it could be changed with some kernel tinkering.As shown above, there is some way in Linux to employ VRAM as swap space. Such use doesn't suffer from caching and latency problems because swap is accessed in 4KB pages, but of course swapping in a whole page has more latency than the data access which triggers it.editThe link above is some weird stuff.See also herehttps://wiki.archlinux.org/index.php/Swap_on_video_RAM

author: brucehoult
author_rank: Super Contributor
timestamp: October 23, 2020, 09:10:53 am
content: https://github.com/prsyahmi/GpuRamDrive/You should be able to use the same cuda calls as this uses to just use it as extra RAM. This Windows source but the guts should be able to be ported to Linux.It seems in some cases ("GPU_API == GPU_API_HOSTMEM") you can just use standard memcpy() to copy data between CPU and GPU, but in other cases you need to use cuMemcpyHtoD() or clEnqueueWriteBuffer().I don't know what determines what API is available.See GPURamDrive::GpuAllocateRam(), GPURamDrive::GpuWrite(), GPURamDrive::GpuRead() inhttps://github.com/prsyahmi/GpuRamDrive/blob/master/GpuRamDrive/GpuRamDrive.cpp

author: brucehoult
author_rank: Super Contributor
timestamp: October 23, 2020, 09:11:50 am
content: Quote from: Jeroen3 on October 23, 2020, 09:02:01 amGah, you posted while I was reading code and composing my message...

author: magic
author_rank: Super Contributor
timestamp: October 23, 2020, 09:33:15 am
content: I'm not up to date with the latest developments in CUDA, but up to some 2013~2014 there was no way to map GPU memory into CPU address space with their APIs. The inverse is possible.Quote from: brucehoult on October 23, 2020, 09:10:53 amCUDA and OpenCL availability depends on installed video card and drivers, obviously. As for that other one, everything you need to know is here:Code:void GPURamDrive::GpuAllocateRam(){#if GPU_API == GPU_API_HOSTMEMm_pBuff = new char;