How to get gpu memory consumption via scripting

Hi,

I was wondering what the best way would be to check for gpu memory consumption:

We want to create a test script with python, which checks for current gpu memory consuption of Unreal.

I was trying “pynvml” or “nvidia smi” but it can only give the systems amount of GPU memory used. Not per app.

Is there by any change a command which can get the current gpu memory consumption? In Unreal?

Steps to Reproduce
Hi,

I was wondering what the best way would be to check for gpu memory consumption:

We want to create a test script with python, which checks for current gpu memory consuption of Unreal.

I was trying “pynvml” or “nvidia smi” but it can only give the systems amount of GPU memory used. Not per app.

Is there by any change a command which can get the current gpu memory consumption? In Unreal?

Hi Jan,

Have you tried using memreport, Unreal Memory Insights, or our Low Level Memory tagging features? These are all available within the engine and give detailed insights into the memory consumption of your application. Memory Insights and LLM tags can also be dumped into a CSV file format, allowing you to parse and visualize the data through Python. I have provided some links to the documentation on these utilities here:

https://dev.epicgames.com/documentation/en\-us/unreal\-engine/using\-the\-low\-level\-memory\-tracker\-in\-unreal\-engine

https://dev.epicgames.com/documentation/en\-us/unreal\-engine/memory\-insights\-in\-unreal\-engine

Please let me know if you have any further questions.

Thanks for the tips! I think memreport looks very promising.

The Unreal Editor currently consumes around 13.5 GB on my side. In memreport I have:

13163.828MB - _Total Allocated - STAT_VulkanMemoryTotal - STATGROUP_VulkanMemoryRaw - STATCAT_Advanced

Can I assume that this value is more or less the amount what Unreal uses of the gpu memory?

I attached an image with all the Vulkan memory consumption if you see some other value which is more fitting for gpu consuption.

[Image Removed]

Hi there,

Yes, the output of STAT_VulkanMemoryTotal should be the total GPU memory consumed by the Vulkan driver. One way to check this is to cross-check it with the STAT_VulkanMemoryUsage#, which are stats based on the VK_EXT_memory_budget extension. Those stats should be in the same ballpark, usually as STAT_VulkanMemoryTotal. Please let me know if you have any further questions.

Thanks a lot!

I guess STATGROUP_RHI is also everything GPU memory related.

One more thing. I am curious what is triggering these entries.

773\.131MB \- BufferOther \- STAT\_VulkanAllocation\_BufferOther \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

 0\.000MB \- BufferStaging \- STAT\_VulkanAllocation\_BufferStaging \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

 0\.000MB \- BufferUAV \- STAT\_VulkanAllocation\_BufferUAV \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

428\.245MB \- ImageOther \- STAT\_VulkanAllocation\_ImageOther \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

-755.956MB - ImageRenderTarget - STAT_VulkanAllocation_ImageRenderTarget - STATGROUP_VulkanMemory - STATCAT_Advanced

 0\.000MB \- FrameTempBuffer \- STAT\_VulkanAllocation\_FrameTempBuffer \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

 0\.000MB \- RingBuffer \- STAT\_VulkanAllocation\_RingBuffer \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

4734.779MB - MultiBuffer - STAT_VulkanAllocation_MultiBuffer - STATGROUP_VulkanMemory - STATCAT_Advanced

 1\.332MB \- UniformBuffer \- STAT\_VulkanAllocation\_UniformBuffer \- STATGROUP\_VulkanMemory \- STATCAT\_Advanced

I am glad to hear the information is helping you. Which two entries specifically are you talking about here?

Hi, I am fine for now. Thanks a lot :slight_smile:

You are welcome! With that, I will close out the ticket.