I'm trying to get the doMPI package running on my local machine, so that I can perform testing on it before submitting jobs to a cluster. I am using Mac OSX Yosemite and have installed open mpi 2.0.2 via brew.

mpirun -V

mpirun (Open MPI) 2.0.2

Report bugs to http://www.open-mpi.org/community/help/

I have read over the introduction for doMPI and I'm trying to execute the example in the demo

mpirun -H localhost R --slave -f sincMPI.R

Unfortunately I get keep getting the following error. I've googled around but can't seem to figure out what might be wrong.

> Loading required package: foreach Loading required package: iterators
> Loading required package: Rmpi
> --------------------------------------------------------------------------
> There are not enough slots available in the system to satisfy the 2
> slots that were requested by the application:  
> /Library/Frameworks/R.framework/Resources/bin/Rscript
> 
> Either request fewer slots for your application, or make more slots
> available for use.
> --------------------------------------------------------------------------
> Error in mpi.comm.spawn(slave = rscript, slavearg = args, nslaves =
> count,  :    MPI_ERR_SPAWN: could not spawn processes Calls:
> startMPIcluster -> mpi.comm.spawn -> .Call Execution halted
> ------------------------------------------------------- 
> Primary job  terminated normally, but 1 process returned a non-zero exit code.. 
>Per user-direction, the job has been aborted.
> -------------------------------------------------------
> --------------------------------------------------------------------------
> mpirun detected that one or more processes exited with non-zero
> status, thus causing the job to be terminated. The first process to do
> so was:
> 
>   Process name: [[27630,1],0]   Exit code:    1

EDITED: Results of test based on the answer below

Worked as specified:

mpirun -H localhost,localhost,localhost R --slave -f sincMPI.R

I took out the count=2 from startMPIcluster() and it also worked.

startMPIcluster() #in sincMPI.R 
mpirun -H localhost,localhost,localhost R --slave -f sincMPI.R

If you take out the count=2, you can vary the number of hosts in mpi run. Here I specify four hosts.

startMPIcluster() #in sincMPI.R 
mpirun -H localhost,localhost,localhost,localhost R --slave -f sincMPI.R

You can even use this method to specify more than the number of available cores. I have 8 (logical) cores, but I can specify 9 hosts and it runs.

mpirun -H localhost,localhost,localhost,localhost,localhost,localhost,localhost,localhost,localhost R --slave -f sincMPI.R

However, you can't put count=9 into startMPIcluster()

startMPIcluster(count=9)  
Error in startMPIcluster(count = 9) :    
  count must be either unspecified, or set to 8 
Execution halted

So, perhaps the best approach for testing mpi on a mac is to not set count in startMPIcluster, and use -H to control the number of tasks?

1

There are 1 best solutions below

1
On BEST ANSWER

By using the mpirun -H localhost option, the MPI universe size is only one, and that is causing mpi.comm.spawn to fail when the example calls startMPIcluster. If you use -H localhost,localhost,localhost, the universe size will be three and the example should work.


Update

Note that I only call startMPIcluster with a count argument when executing interactively on a single computer (that is, when I'm not using mpirun). When executing a doMPI script with mpirun, I find it easier to control the number of workers via mpirun.