cd /path/to/mpi4py
vim test.py
from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() print ('My rank is ', rank)
mpirun --allow-run-as-root -np 4 python3 test.py
回显显示信息如下图所示。