mdolab / pyoptsparse

pyOptSparse is an object-oriented framework for formulating and solving nonlinear constrained optimization problems in an efficient, reusable, and portable manner.
https://mdolab-pyoptsparse.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
228 stars 109 forks source link

Different behavior of Popen with and without pyoptsparse. #358

Closed NAnand-TUD closed 1 year ago

NAnand-TUD commented 1 year ago

Description

I installed pyoptsparse using the build_pyoptsparse repo on openMDAO git page. The import and everything is working fine, however, it seems that pyoptsparse has some interference with the subprocess package.

Steps to reproduce issue

So Running

import subprocess as sp
sp.Popen('mpirun -n 2 SU2_CFD flow.cfg')

I get the SU2 running.

However with the one below,

import subprocess as sp
import pyoptsparse
sp.Popen('mpirun -n 2 SU2_CFD flow.cfg')

Perhaps anyone in the community has faced a similar problem? Or has knowledge of possible interference?

Thanks Nitish

marcomangano commented 1 year ago

Hi Nitish, I suspect you might be encountering something similar to what has been discussed here. One of the dependencies imports mpi4py and that might be causing issues in your environment. Do you experience this issue any time you use Popen or specifically when you call mpirun?

NAnand-TUD commented 1 year ago

Hi Marco,

Thanks for your swift response. I made some checks and indeed the issue was with mpi.

Unfortunately the option PYOPTSPARSE_REQUIRE_MPI=NO did not work for me. I have no clue why. However, I explicitly installed mpi4py and now pyoptsparse works with Popen, though it shows a small waning.

I can use Pyoptsparse now and can continue with my optimization.

Thanks again for your help.

Cheers, Nitish

marcomangano commented 1 year ago

Good to know you found a workaround @NAnand-TUD! Do you mind sharing the warning here for future reference?

NAnand-TUD commented 1 year ago

Definitely, that is the least I can do for your help.

UserWarning: mpi4py could not be imported. mpi4py is required to use the parallel gradient analysis and parallel objective analysis for non-gradient based optimizers. Continuing using a dummy MPI module from pyOptSparse.