I have a python code, which runs another application using subprocess.Popen and mpirun.
Will the code runs perfectly fine on one machine, on the other I run into problems.
But I have also an older conda environment where it works.
The minimal code to reproduce is the following:
from subprocess import Popen
from mpi4py import MPI
proc = Popen("mpirun -n 2 echo 1".split())
At this line proc immediately terminates and proc.poll() returns 1. The python scrip doesn't actually use MPI, it is simply run as python script.py, it depends however on another program calling MPI. I need to repeatedly run another code with mpirun (Of course I don't actually execute echo 1).
I assume it depends on the installed MPI:
Working:
$ conda list -n ForkTPS | grep mpi
WARNING: The conda.compat module is deprecated and will be removed in a future release.
fftw 3.3.8 mpi_mpich_hc19caf5_1012 conda-forge
h5py 2.10.0 nompi_py38h7442b35_105 conda-forge
hdf5 1.10.6 mpi_mpich_hc096b2c_1010 conda-forge
mpi 1.0 mpich conda-forge
mpi4py 3.0.3 py38h4a80816_2 conda-forge
mpich 3.3.2 hc856adb_2 conda-forge
as well as
conda list | grep mpi
dask-mpi 2.21.0 pypi_0 pypi
fftw 3.3.8 mpi_mpich_h3f9e1be_1011 conda-forge
hdf5 1.10.5 mpi_mpich_ha7d0aea_1004 conda-forge
impi_rt 2019.8 intel_254 intel
libnetcdf 4.7.4 mpi_mpich_h755db7c_1 conda-forge
mpi 1.0 mpich
mpi4py 3.0.3 py37hf484d3e_7 intel
mpich 3.3.2 hc856adb_0 conda-forge
netcdf4 1.5.3 mpi_mpich_py37h91af3bc_3 conda-forge
Not working:
conda list | grep mpi
fftw 3.3.8 mpi_openmpi_h6dd7431_1011 conda-forge
hdf5 1.10.6 mpi_openmpi_hac320be_1 conda-forge
mpi 1.0 openmpi conda-forge
mpi4py 3.0.3 py38h246a051_2 conda-forge
openmpi 4.0.5 hdf1f1ad_1 conda-forge
Is there a reasonable and reproducible way to avoid this issue? I have to make my code available to several collaborators. At first glance, I would say the difference is using MPICH vs OpenMPI.
mpirun -np 1 echo 1from the command line? and thenmpirun -np 2 echo 1?