PhysicalAddons / physical-starlight-and-atmosphere

issue tracker
16 stars 2 forks source link

Out of memory #47

Closed AlstonJones closed 3 years ago

AlstonJones commented 3 years ago

Describe the bug Out of Memory error message when trying to render image with Clouds on. Render is slow in Eevee as well. Rendering works without clouds and when using other lighting setups. I have run diagnostics and benchmarks to make sure my GPU is running at top speed and I've optimized Blender. I could use some smaller textures in my scene but I figure it might be worth knowing that this is quite a drain on my memory.

General information

To Reproduce [Replace this with a steps to reproduce the behavior]

Screenshots [If applicable, add screenshots to help explain your problem.]

karlisup commented 3 years ago

Hi @AlstonJones, Thank you for your patience! I think that this ticket is worth keeping open. Although @martinsh is already is working on this there are no specific tickets about the fact that clouds are being very memory draining.

AlstonJones commented 3 years ago

I mentioned this problem to the Blender developers and they gave me this response which I think will clarify where the problem is. https://developer.blender.org/T90440 Error: System is out of GPU and shared host memory

As the error message implies, you are out of memory. When trying yo render these scene on my computer, also with 64GB of RAM, it fills it all up plus an extra 30GB of SWAP (Pagefile) before I decided to close Blender. That means your scene takes up 90GB or more when trying to render, this easily exceeds the 8GB of VRAM + 64GB of RAM and probably the pagefile you have, and that's why you get that error.

As for what's causing it, I did some testing and this is what I observed: The cause for this issue is the materials used by objects. Specifically the StarlightAtmosphere node group from the Physical Starlight and Atmosphere add-on. The node group is rather complex, and as such it takes up a bit of RAM. However, this isn't the issue, the amount of RAM is probably measured in tens of megabytes at the most. The issue is that you've re-used the node group a lot. You've given the node group to every material in the scene meaning that it now has to be stored for every material, which means more RAM is taken up. But once again, this probably isn't the issue, it's probably only going to take up hundreds of megabytes at the most. The issue is that you gave this node group to the "Grasswald" objects, the ones scattered using a particle system onto your landscape. The node group takes information about object position and distance from the camera and such that needs to be re-computed every time the Grasswald objects are scattered. Which is 472,024 times. And these calculations have to be stored in RAM. So although the node group only takes up a couple megabytes at most, it has to be duplicated 472,024 times, which means it takes up lots of RAM and results in the issue you're experiencing.

Removing the StarlightAtmosphere node group from the Grasswald objects resolves the issue with running out of memory. As such, I do not believe this is a bug and this report can probably be closed? I will wait for a developer to decide on this.

karlisup commented 3 years ago

Thank you @AlstonJones for taking this to the Blender developers forum! This in-depth analysis by Alaska is of this issue is amazing! The issue is on our side and has already been partially reported in #17. I have to rediscuss this topic with @martinsh as I think that it probably will be solved with the upcoming performance fix which is a huge node setup redesign.

AlstonJones commented 3 years ago

Great! I'm so happy I could help! I love your product and I want to use it whenever I can. Looking forward to the next big fix. And the clouds are a wonderful addition by the way.

karlisup commented 3 years ago

Hi there, We have improved the performance of the fog (roughly by 6? times) in PSA v1.4.2-beta. We also have added more controls over the fog. I cannot say if this will solve the particular issue, but it can be avoided using the new controls. For example, by applying object fog to all objects before adding Grasswald objects to the scene. It still sounds quite tricky, but currently, there is no silver bullet for the problem. Best of luck and hope you will enjoy new features!

AlstonJones commented 3 years ago

Great! Thanks for letting me know. I've already downloaded 1.4.2-beta and I really do enjoy the new features. I'll have to try out your workflow suggestions and see what works best. Looking forward to continuing use of your wonderful addon. I've already used it in several projects and it really enhances a scene with minimal effort.