How to initialize mpi4py

214 views
Skip to first unread message

Yin Lou

unread,
Dec 11, 2009, 11:51:14 PM12/11/09
to mpi4py
Hi All,

I'm very new to MPI and mpi4py.

My first question is that whether or not "mpiexec -n 5 python test.py"
would run test.py on local host.I mean the 5 processes.

My second question is that how to run mpi4py in a real distributed
model. I tried "mpirun -machinefile hostfile -np 5 python test.py",
but it says I'll need rsa to go on and I have no idea how to solve
that.

Thanks all!

Lisandro Dalcin

unread,
Dec 12, 2009, 12:08:26 AM12/12/09
to mpi...@googlegroups.com
On Sat, Dec 12, 2009 at 1:51 AM, Yin Lou <yin.l...@gmail.com> wrote:
> Hi All,
>
> I'm very new to MPI and mpi4py.
>

Wellcome!

> My first question is that whether or not "mpiexec -n 5 python test.py"
> would run test.py on local host.I mean the 5 processes.
>

That depends on the MPI implementation. For example, in the case of
MPICH2 with the MPD process manager, you have to use something like
'mpdboot -n 5 -f hostfile', and next you can 'mpiexec -n 5 ...'. In
the case of Open MPI you can do 'mpiexec -machinefile hostfile -n 5
...'

If you just 'mpdboot' in MPICH2 case, or does not pass '-machinefile
hostfile' to mpiexec in the case of Open MPI, then all your processes
will run on the same host. If you have a multicore Desktop box, this
is a way to take advantage of all your cores in a Python application.


So in short, you have to RTFM of you MPI implementation to figure out
how to launch parallel MPI jobs.

> My second question is that how to run mpi4py in a real distributed
> model. I tried "mpirun -machinefile hostfile -np 5 python test.py",
> but it says I'll need rsa to go on and I have no idea how to solve
> that.
>

That likely means that you need to have password-less SSH
autenticacion to all the machines in hostfile.
See this FAQ entry http://www.open-mpi.org/faq/?category=rsh#ssh-keys

Basically, you have to do this:

shell$ ssh-keygen -t dsa # NOTE: use an empty phrase, i.e, just hit <ENTER>
shell$ cd $HOME/.ssh
shell$ cp id_dsa.pub authorized_keys

now, to make sure all is working, do this:

shell$ mpiexec -machinefile hostfile -n 5 hostname

you should get 5 lines of output, each one showing 5 different hosts
from the ones listed in hostfile.


--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
Reply all
Reply to author
Forward
0 new messages