Hi!
I get a weird “memory leak” when importing memory from Vulkan using Virtual Memory Management functions.
The memory is imported using these functions:
Initialization:
cuMemAddressReserve
Every frame:
Vulkan: GetMemoryWin32HandleKHR
cuMemImportFromShareableHandle
cuMemMap
cuMemSetAccess <--- No leak when this is removed
cuMemUnmap
cuMemRelease
When I call cuMemGetInfo I see some memory usage after cuMemSetAccess.
After cuMemRelease the memory is available again.
This works fine for the first ~2500 mappings/unmappings.
After that point cuMemRelease does not lead to more available memory, reported by cuMemGetInfo, anymore.
The reported available memory slowly shrinks to between 3 and 4GB.
At this point everything gets very slow (~40ms for mapping+unmapping), but the application still works as expected.
After ~32000 frames I get out of memory from cuMemSetAccess.
This does not happen when the call to cuMemSetAccess is removed (though the memory is not usable then).
cuMemGetInfo also does not report any additional memory consumption when cuMemSetAccess is not called.
ProcessExplorer reports no additional memory usage for each frame, which is expected.
All the memory is already allocated by Vulkan. Cuda should not allocate any physical memory.
Why does it report memory usage at all?
Am I doing something wrong here, or is this a bug?
My system:
Windows 11 21H2 (OS Build 22000.2538)
GPU RTX 3090
driver version 555.99
Cuda version: 12.5
I also tried this on several other PCs.
On another system with a 3090 I could reproduce the behavior. On two PCs with a 4090 I could not reproduce it.