Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Redirect stdout from MPI_Comm_spawn to a file in mpi4py

77 views
Skip to first unread message

Pavankumar Koratikere

unread,
Jan 2, 2023, 10:46:46 AM1/2/23
to mpi4py

I have a runscript.py file that outputs a lot of stdout on the terminal. I run the script from command line using mpirun -n 8 python runscript.py >> analysis.log which redirects the stdout to analysis.log file.

Instead of running the script from command line, I am using MPI.COMM_WORLD.Spawn(sys.executable, args=["runscript.py"], maxprocs=8) from another script. I want to redirect stdout from only the spawned process and not from the main script. Is there a way to redirect stdout to a file from child processes spawned using MPI.COMM_WORLD.Spawn() method?

OpenMPI: 4.0.7
mpi4py: 3.1.3

Lisandro Dalcin

unread,
Jan 25, 2023, 8:33:17 AM1/25/23
to mpi4py
I don't really know. Ultimately, the behavior would depend on the backend MPI implementation, this is not something mpi4py has control of. You should ask Open MPI folks.

Pavankumar Koratikere

unread,
Jan 28, 2023, 8:51:26 PM1/28/23
to mpi4py
I found a way to do this by changing the file descriptor from python using os.dup().

William Handley

unread,
Nov 28, 2024, 7:35:19 PM11/28/24
to mpi4py
> I found a way to do this by changing the file descriptor from python using os.dup().

Could you give any more detail?

Pavankumar Koratikere

unread,
Nov 29, 2024, 2:01:16 PM11/29/24
to mpi4py

Answer provides an example of how to use os.dup()
Reply all
Reply to author
Forward
0 new messages