Memory stats while rendering

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
Post Reply
Luxart
Posts: 49
Joined: Tue Feb 13, 2018 10:14 am

Memory stats while rendering

Post by Luxart »

Hi Dade,
Luxcore not displays memory used in rendering stats. Previously Luxrender displays like (Memory: 325MB / 3071 MB).
Could you please add this feature as it will be useful in rendering large scenes in GPU. Thanks.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Memory stats while rendering

Post by B.Y.O.B. »

Luxart
Posts: 49
Joined: Tue Feb 13, 2018 10:14 am

Re: Memory stats while rendering

Post by Luxart »

Hi BYOB,

After some addition and deletion of the old code, I made the following code to work out the memory usage of GPU.

I added it after # Triangle count code in get_pretty_stats function.

# Memory usage (only available for OpenCL engines)
if str.endswith(engine, 'OCL'):
device_stats = stats.Get("stats.renderengine.devices")

max_memory = float('inf')
used_memory = 0

for i in range(device_stats.GetSize()):
device_name = device_stats.GetString(i)

# Max memory available is limited by the device with least amount of memory
device_max_memory = stats.Get("stats.renderengine.devices." + device_name + ".memory.total").GetFloat()
device_max_memory = int(device_max_memory / (1024 * 1024))
if device_max_memory < max_memory:
if device_max_memory != 0:
max_memory = device_max_memory

device_used_memory = stats.Get("stats.renderengine.devices." + device_name + ".memory.used").GetFloat()
device_used_memory = int(device_used_memory / (1024 * 1024))
if device_used_memory > used_memory:
used_memory = device_used_memory

pretty.append('Memory: %d MB/%d MB' % (used_memory, max_memory))


At first the code returns used_memory perfectly but max_memory always was 0.

When I checked the system console, Besides CPU and GPU it displays a device NATIVE_THREAD with max memory = 0.
It might be because of that. So i introduced the following line in code.

if device_max_memory != 0:

After that it perfectly returns the GPU memory size as 3072 MB for AMD (R9 280x/ 7970).

I know C++ programming not python, so the code is a rough implementation ;) .
Hope it is helpful :D .
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Memory stats while rendering

Post by B.Y.O.B. »

When you edit your post, click the 5th button (icon </>) to create code tags so the indentation is not lost:

Code: Select all

if bla:
    blub()
By the way, did you check the stuff mentioned as todo in the issue?
When implementing this, check if stats.renderengine.devices really only returns the enabled devices (important for max. available memory calculation).
P.S. you can also create a pull request, like described here: viewtopic.php?f=5&t=135
Luxart
Posts: 49
Joined: Tue Feb 13, 2018 10:14 am

Re: Memory stats while rendering

Post by Luxart »

By the way, did you check the stuff mentioned as todo in the issue?
When implementing this, check if stats.renderengine.devices really only returns the enabled devices (important for max. available memory calculation).
I missed that point. Also I have single GPU and can't test this feature :roll:

P.S. you can also create a pull request, like described here: viewtopic.php?f=5&t=135
[/quote]

In future I will do it that way (Hope those steps are easy to follow :? ).
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Memory stats while rendering

Post by B.Y.O.B. »

Luxart wrote: Sun Apr 29, 2018 8:13 am I missed that point. Also I have single GPU and can't test this feature
Damn. I think this is more work than the actual coding.
Luxart wrote: Sun Apr 29, 2018 8:13 am In future I will do it that way (Hope those steps are easy to follow)
If you have to set it up the first time for such a small patch, it will seem like much work for little impact.
But if you submit more patches in the future, it takes a lot of work off of our shoulders if we can just review pull requests instead of copy/pasting code from the forum.

Thank you for your interest in contributing :)
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Memory stats while rendering

Post by Dade »

B.Y.O.B. wrote: Sun Apr 29, 2018 8:41 am If you have to set it up the first time for such a small patch, it will seem like much work for little impact.
But if you submit more patches in the future, it takes a lot of work off of our shoulders if we can just review pull requests instead of copy/pasting code from the forum.
You will also appear has author of the patch in official source code repositories. Something that is totally lost if someone else commit the code for you.
Support LuxCoreRender project with salts and bounties
Luxart
Posts: 49
Joined: Tue Feb 13, 2018 10:14 am

Re: Memory stats while rendering

Post by Luxart »

Dade wrote: Sun Apr 29, 2018 9:53 am
B.Y.O.B. wrote: Sun Apr 29, 2018 8:41 am If you have to set it up the first time for such a small patch, it will seem like much work for little impact.
But if you submit more patches in the future, it takes a lot of work off of our shoulders if we can just review pull requests instead of copy/pasting code from the forum.
You will also appear has author of the patch in official source code repositories. Something that is totally lost if someone else commit the code for you.
Hi,

At present I'm playing with LuxCore C++ code (totally biased ideas).

Once I can significantly contribute to the project, I will create requests in github.

Meanwhile, I observed some small cleanups in Luxcore code. as the changes are very small and taking time (learning github process) into consideration, I'm posting it in seperate thread in this forum.
Next time I will do it in github :) .
Post Reply