[R-sig-hpc] Recommended way to exit cleanly from MPI cluster?

Bjørn-Helge Mevik b.h.mevik at usit.uio.no
Wed Apr 20 15:08:05 CEST 2016


Dear All,

I'm wondering what is the currently recommended way of exiting cleanly
after using a MPI cluster with the parallel (or snow) package.

My reason for asking is the following:
I'm managing an HPC cluster at the University of Oslo, and we have
recommended that our users use MPI with R like this:


################################
library(parallel)

## Start the MPI worker processes:
numWorkers <- as.numeric(Sys.getenv("SLURM_NTASKS")) - 1
myCluster <- makeCluster(numWorkers, type = "MPI")

## Define a worker function:
workerFunc <- function(n) {
    return(n^2)
}
## and a list or vector to use it on:
values <- 1:100

## Apply workerFunc to values in parallel:
results <- parLapply(myCluster, values, workerFunc)
print(unlist(results))

## Exit cleanly:
stopCluster(myCluster)
mpi.exit()                              # or mpi.quit(), which quits R as well
################################


However, as of snow 0.4-1, Rmpi is no longer attached on the search
path, so mpi.exit() and mpi.quit() are not visible.


After a bit of testing and reading, I've discovered that

stopCluster(myCluster)
Rmpi::mpi.finalize()

and

stopCluster(myCluster)
Rmpi::mpi.quit()

work, the latter of which will also exit R.

Are these the currently recommended ways to exit cleanly after using MPI
clusters?

-- 
Bjørn-Helge Mevik, dr. scient,
Department for Research Computing, University of Oslo



More information about the R-sig-hpc mailing list