Chris Carleton
2011-Feb-01 16:01 UTC
[R] Rmpi; sample code not running, the slaves won't execute commands
Hi All, I'm trying to parallelize some code using Rmpi and I've started with a sample 'hello world' program that's available at http://math.acadiau.ca/ACMMaC/Rmpi/sample.html. The code is as follows; # Load the R MPI package if it is not already loaded. if (!is.loaded("mpi_initialize")) { library("Rmpi") } # Spawn as many slaves as possible mpi.spawn.Rslaves(nslaves=3) # In case R exits unexpectedly, have it automatically clean up # resources taken up by Rmpi (slaves, memory, etc...) .Last <- function(){ if (is.loaded("mpi_initialize")){ if (mpi.comm.size(1) > 0){ print("Please use mpi.close.Rslaves() to close slaves.") mpi.close.Rslaves() } print("Please use mpi.quit() to quit R") .Call("mpi_finalize") } } # Tell all slaves to return a message identifying themselves mpi.remote.exec(paste("I am",mpi.comm.rank(),"of",mpi.comm.size())) # Tell all slaves to close down, and exit the program mpi.close.Rslaves() mpi.quit() My output is as follows;> source("./test_Rmpi.R")3 slaves are spawned successfully. 0 failed. master (rank 0, comm 1) of size 4 is running on: minanha slave1 (rank 1, comm 1) of size 4 is running on: minanha slave2 (rank 2, comm 1) of size 4 is running on: minanha slave3 (rank 3, comm 1) of size 4 is running on: minanha While trying to parallelize one of my other functions, I found that the master seems to be sending the messages and executing its portion of the program, but the slaves are not responding. However, the slaves do seem to send the initial message to the master that they are ready to receive a job, which prompts the master to send the job. So, noticing that problem, I tried to execute the 'hello world' program above and, as you can see, the slaves are spawned, but they won't print the text in the mpi.remote.exec() function. Any ideas? Chris
Patrick Connolly
2011-Feb-09 08:36 UTC
[R] Rmpi; sample code not running, the slaves won't execute commands
On Tue, 01-Feb-2011 at 11:01AM -0500, Chris Carleton wrote: [...] |> |> My output is as follows; |> |> > source("./test_Rmpi.R") How was test_Rmpi.R created? Was it using sink()? |> 3 slaves are spawned successfully. 0 failed. |> master (rank 0, comm 1) of size 4 is running on: minanha |> slave1 (rank 1, comm 1) of size 4 is running on: minanha |> slave2 (rank 2, comm 1) of size 4 is running on: minanha |> slave3 (rank 3, comm 1) of size 4 is running on: minanha |> [...] |> noticing that problem, I tried to execute the 'hello world' program |> above and, as you can see, the slaves are spawned, but they won't |> print the text in the mpi.remote.exec() function. Any ideas? Are you saying that there was no response at all from the other three lines? They work fine for me. I suspect that you have something not quite finished with your MPI setup. I doubt the problem is with Rmpi itself, but then of course, there's not much to work on. HTH -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.