简体   繁体   中英

Script in mpi4py not executing correctly

I'm developing a cluster using mpi4py and when i run a basic script to test the cluster the result is weird:

在此处输入图像描述

the result should be this (script executed in c):

在此处输入图像描述

My code:

from mpi4py import MPI

world_comm = MPI.COMM_WORLD
world_size = world_comm.Get_size()
name = MPI.Get_processor_name()
my_rank = world_comm.Get_rank()

print('World Size: {0} | Name: {1} | Rank: {2}'.format(world_size,name,my_rank))

And the hostfile:

no02   slots=3 
no01   slots=5 

How could I get around this problem?

I managed to solve it as follows: I reinstalled mpi4py, but this time I passed the MPICC env before installation:

env MPICC=/usr/bin/mpicc pip3 install mpi4py --no-cache-dir

But you need to make sure the libopenmpi-dev library is installed and then run the which mpicc command and put it as a path in the env in the above command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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