1
votes

I've installed mpi4py and was trying to write my own python code to run across nodes. The demo folder for the MPI for python package had a hello world script that I executed and it ran successfully with the following output:

I've got 2xraspberrypi's (quad cores) and the output came out right!

Command: mpiexec --hostfile machinefile -n 8 python ~/mpi4py/mpi4py-3.0.3/demo/helloworld.py
Output:

Hello, World! I am process 0 of 8 on node001.
Hello, World! I am process 1 of 8 on node001.
Hello, World! I am process 2 of 8 on node001.
Hello, World! I am process 3 of 8 on node001.
Hello, World! I am process 6 of 8 on node002.
Hello, World! I am process 7 of 8 on node002.
Hello, World! I am process 4 of 8 on node002.
Hello, World! I am process 5 of 8 on node002.

I attempted to create a python script and copy-pasted the python script from the demo folder and ran the following command:

Command: mpiexec --hostfile machinefile -n 8 python ~/Desktop/sct/sct.py 

But my output was only limited to four prints:

Hello, World! I am process 2 of 8 on node001.
Hello, World! I am process 3 of 8 on node001.
Hello, World! I am process 0 of 8 on node001.
Hello, World! I am process 1 of 8 on node001.

It's the exact same code copy pasted. I don't understand whats going wrong. It should print out 8 times like it did from the demo folder but here it just prints out 4.

In case y'all need the code in the python script its:

#!/usr/bin/env python
"""
Parallel Hello World
"""

from mpi4py import MPI
import sys

size = MPI.COMM_WORLD.Get_size()
rank = MPI.COMM_WORLD.Get_rank()
name = MPI.Get_processor_name()

sys.stdout.write(
    "Hello, World! I am process %d of %d on %s.\n"
    % (rank, size, name))

Please help!

1

1 Answers

1
votes

Silly me.. I didn't copy the script from my master node to my worker node. The script was executing from the master nodes side.