简体   繁体   English

如果处理器0上的断言失败,以mpirun运行的python脚本不会停止

[英]python script running with mpirun not stopping if assert on processor 0 fails

I have a python script with a set of operations done in parallel, with the library mpi4py. 我有一个python脚本,带有一组并行执行的操作,以及库mpi4py。 At the end of the operations the processor with rank 0 executes an assert test. 在操作结束时,等级为0的处理器将执行断言测试。 If the assert fails, the process should stop and the program terminate. 如果断言失败,则该过程应停止并且程序终止。 However, the program doesn't exit and this I guess is because the other processors are holding. 但是,该程序没有退出,我想这是因为其他处理器正在处理。 How to make the program ending the execution if the assert fails? 如果断言失败,如何使程序结束执行? I run things with a command like: 我使用以下命令运行内容:

mpirun -np 10 python myscript.py 

and then I have a line in the code like: 然后我在代码中一行:

if rank ==0:
    assert mytest()==0

Instead of assert, you should abort. 而不是断言,您应该中止。

https://planet.scipy.org/docs/apiref/mpi4py.MPI.Comm-class.html#Abort https://planet.scipy.org/docs/apiref/mpi4py.MPI.Comm-class.html#Abort

if rank == 0:
    if mytest() === 0:
        comm.Abort()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM