Spawn error

436 views
Skip to first unread message

Conn O'Rourke

unread,
Dec 1, 2016, 6:11:56 AM12/1/16
to mpi4py
Hi Guys,

I have an error using anaconda to run a task farm code I am playing about with.

Any suggestions as to what is causing the problem would be appreciated.

The code has a wrapper super_master.py, that should spawn a single instance of master.py, which then spawns instances of slave.py to work through a set of tasks. The reason I am using this wrapper is that the code is a test case to be included in another piece of code, which is run from the terminal without invoking mpi, so I want the wrapper to invoke it.

The error I get is:

[mpiexec@itd-ngpu-01] match_arg (./utils/args/args.c:122): unrecognized argument pmi_args
[mpiexec@itd-ngpu-01] HYDU_parse_array (./utils/args/args.c:140): argument matching returned error
[mpiexec@itd-ngpu-01] parse_args (./ui/mpich/utils.c:1387): error parsing input array
[mpiexec@itd-ngpu-01] HYD_uii_mpx_get_parameters (./ui/mpich/utils.c:1438): unable to parse user arguments

Usage: ./mpiexec [global opts] [exec1 local opts] : [exec2 local opts] : ...

If i use an os call:

os.system('{}'.format('mpirun -np 1 python master.py'))

in super_master.py it runs fine, but I was curious as to why the issue arises using spawn. At a guess my spawn call in super_master.py is formatted incorrectly, but I can't see the problem.....

Thanks!
code follows:



super_master.py:


#!/usr/bin/env python
import os
from mpi4py import MPI
import sys

comm
= MPI.COMM_WORLD
print(sys.executable)
new_comm
=comm.Spawn(sys.executable,args=["/path/to/master.py"],maxprocs=1)

master.py:

#!/usr/bin/env python
from mpi4py import MPI
import numpy as np
import sys
import os
import time


comm
= MPI.COMM_WORLD
rank
= MPI.COMM_WORLD.Get_rank()

processes
=4

tasks
=([StopIteration] * (processes))+[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

new_comm
=comm.Spawn("/path/to/slave.py",
                  args
=[],maxprocs=processes)


status
=MPI.Status()



#if rank == 0:
while tasks:
    new_comm
.recv(source=MPI.ANY_SOURCE, status=status)
    data
=tasks.pop()
   
print("on master received source: ",status.Get_source())
   
print("On master sending: ",data," to:",status.Get_source())
    new_comm
.send(obj=data,dest=status.Get_source())
   
print("On master sent: ",data," to:",status.Get_source())


new_comm
.Barrier()
new_comm
.Disconnect()

print("Finished All",rank)


slave.py:

#!/usr/bin/env python
from mpi4py import MPI
import numpy as np
import sys
import os
import time

comm
= MPI.Comm.Get_parent()
rank
= comm.Get_rank()
cwd
=os.getcwd()

print("slave", rank," entering loop")


for task in iter(lambda: comm.sendrecv(dest=0), StopIteration):
   
print("slave ", rank," recvd data", task)
    directory
=os.path.join(cwd,str(task))
    os
.chdir(directory)
    info
= MPI.Info.Create()
    info
.update({"wdir": directory})

    new_comm
=MPI.COMM_SELF.Spawn("/path/to/some/mpi/executable/to/run/on/task",
                  args
=[],maxprocs=4,info=info)

    new_comm
.Barrier()
    new_comm
.Disconnect()
    info
.Free()
    os
.chdir(cwd)

comm
.Barrier()
comm
.Disconnect()


Lisandro Dalcin

unread,
Dec 1, 2016, 6:46:03 AM12/1/16
to mpi4py
How are you executing super_master.py? If you are using MPICH with the Hydra process manager, you have to do:

$ mpiexec -n 1 python super_master.py

or maybe just (assuming you chmod +x super_master.py)

$ mpiexec -n 1 super_master.py

The Hydra PM does not support spawning in the "singleton MPI init" case, that is, you cannot Spawn() from a process that was not launched by mpiexec.



--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+unsubscribe@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/19cb3303-a78d-42cf-8eb2-53f02a01dba1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459

Conn O'Rourke

unread,
Dec 1, 2016, 8:12:13 AM12/1/16
to mpi4py
That's great Lisandro, thanks for the pointer.

So I will have to launch the original code with mpiexec. I was hoping to avoid it, and have one call irrespective of using mpi or not, but I suppose it doesn't really matter.

Thanks again,
Conn
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+un...@googlegroups.com.

To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/19cb3303-a78d-42cf-8eb2-53f02a01dba1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages