Page 1 of 1
Memory stats while rendering
Posted: Thu Feb 22, 2018 2:00 pm
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.
Re: Memory stats while rendering
Posted: Thu Feb 22, 2018 3:48 pm
by B.Y.O.B.
Re: Memory stats while rendering
Posted: Sun Apr 29, 2018 7:40 am
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

.
Re: Memory stats while rendering
Posted: Sun Apr 29, 2018 7:50 am
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:
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
Re: Memory stats while rendering
Posted: Sun Apr 29, 2018 8:13 am
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
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

).
Re: Memory stats while rendering
Posted: Sun Apr 29, 2018 8:41 am
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

Re: Memory stats while rendering
Posted: Sun Apr 29, 2018 9:53 am
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.
Re: Memory stats while rendering
Posted: Mon Apr 30, 2018 7:13 am
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

.