Search code examples
pythonmpiclient-serverhpcmpiexec

How to execute mpirun or mpiexec command from a python script?


I have an MPI application written in C++. When I run the application using mpirun or mpiexec on my local machine shell, it works fine. The problem is that the mpi application should be executed after a request from the network (e.g. HTTP request) is received. Assuming that the application server is written in python, how can I execute the mpi application using mpiexec command from a python script? I used subprocesses.run() command but nothing happens.

My general question: What is the best way to run an MPI application in client/server architecture?

Thank you


Solution

  • I found the solution. In the main python script, MPI should not get imported from mpi4py package. Otherwise subprocess.run("mpiexec") does not do anything.