def _launch_mpisub(self, args, site_dir):
# extract the mpirun run argument
parser = ArgumentParser(add_help=False)
# these values are ignored. This is a hack to filter out unused argv.
parser.add_argument("--single", default=False, action='store_true')
parser.add_argument("--mpirun", default=None)
_args, additional = parser.parse_known_args()
# now call with mpirun
mpirun = args.mpirun.split()
cmdargs = [sys.executable, sys.argv[0], '--mpisub']
if site_dir is not None:
# mpi subs will use system version of package
cmdargs.extend(['--mpisub-site-dir=' + site_dir])
# workaround the strict openmpi oversubscribe policy
# the parameter is found from
# https://github.com/open-mpi/ompi/blob/ba47f738871ff06b8e8f34b8e18282b9fe479586/orte/mca/rmaps/base/rmaps_base_frame.c#L169
# see the faq:
# https://www.open-mpi.org/faq/?category=running#oversubscribing
os.environ['OMPI_MCA_rmaps_base_oversubscribe'] = '1'
os.execvp(mpirun[0], mpirun + cmdargs + additional)
# if we are here os.execvp has failed; bail
sys.exit(1)
评论列表
文章目录