MPI 导入适用于 sbatch 但无法使用 srun

MPI import works with sbatch but fails with srun

尝试在集群上使用 MPI 时,我遇到了一个奇怪的问题,该集群使用 Slurm 作为作业调度程序。在这两种情况下,我都试图 运行 这个简单的 python 程序:

from mpi4py import MPI
print('TEST')

创建批处理脚本(我在其中导出合适的虚拟环境和 运行 这个 python 程序)并将其与 sbatch 一起使用效果很好。

但是,在终端中使用 s运行 运行 相同的程序(在相同的虚拟环境中)会产生以下错误:

*** An error occurred in MPI_Init_thread
*** on a NULL communicator
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
***    and potentially your MPI job)
[w7:564843] Local abort before MPI_INIT completed successfully, but am not able to aggregate error messages, and not able to guarantee that all other processes were killed!
srun: error: w7: task 0: Exited with exit code 1

如果我不导入 MPI,python 脚本会使用 s运行 和 sbatch 正确执行。

Slurm 版本为:19.05.5

OpenMPI 版本为:4.0.3

使用MPI时,s运行和sbatch有什么区别,前者失败,后者成功?我应该更改什么才能使此代码 运行 正确使用 s运行?

运行 带有 srun 和 pmix 支持的作业 ( srun --mpi=pmix_v3 a.out ) 似乎完全解决了这个问题。有关在 pmix 支持下使用 slurm 的更多信息:https://slurm.schedmd.com/mpi_guide.html

我不知道我们的 OpenMPI 是在没有 pmi2 支持的情况下构建的,所以这解释了为什么它不能与 pmi2 一起工作