Open cbyrohl opened 4 years ago
Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue.
This is somewhat mitigated now that you can do:
if yt.is_root():
sc.save("MPI.png", render=False)
and it won't hang. but ideally running sc.save("MPI.png")
should not hang indefinitely, so I think this issue should stay open for now (it'd also be good to add a note on volume rendering in parallel that mentions this)
Bug report
When rendering a scene with yt using MPI and wanting to write the image to disk on rank==0 only, the inspired recipe from the documentation (https://yt-project.org/doc/analyzing/parallel_computation.html#creating-parallel-and-serial-sections-in-a-script) leads to a freeze.
While the example given in the documentation uses a ProjectionPlot as example, I think the documentation page's idea here is to provide a somewhat generic recipe that should also hold for Scenes.
Maybe something can be done about Scene.save() which states
If an image has not yet been rendered for the current scene object, it forces one and writes it out.
but the render is called irrespective of a current scene object having been rendered before thus leading to a freeze, see below.
Code for reproduction
I use a custom scene "sc", which I then call render() on, which is executed by the different ranks. Finally, I only want the root rank to write the rendered image. I attached a minimal snippet below. Note that this snippet uses yt.volume_render() where every rank already writes an image to disk, which of course would make the final write redundant. In reality, often a scene is manually created so that this automatic write per rank does/should not occur.
Execute this snippet with at least two MPI ranks.
Actual outcome
The execution freezes as a new sc.render() is called in sc.save() and only the root process entered the if-clause.
Expected outcome
Write the image through rank==0 without freeze.
Version Information