How to setup workers for parallel processing in R using snowfall and multiple Windows nodes?

There were several options for HPC infrastructure considered: MPICH, Open MPI, and MS MPI. Initially tried to use MPICH2 but gave up as the latest stable release 1.4.1 for Windows dated back by 2013 and no support since those times. Open MPI is not supported by Windows. Then only the MS MPI option is left.

Unfortunately snowfall does not support MS MPI so I decided to go with pbdMPI package, which supports MS MPI by default. pbdMPI implements the SPMD paradigm in contrast withRmpi, which uses manager/worker parallelism.

MS MPI installation, configuration, and execution

  1. Install MS MPI v.10.1.2 on all machines in the to-be Windows HPC cluster.
  2. Create a directory accessible to all nodes, where R-scripts / resources will reside, for example, \HeadMachine\SharedDir.
  3. Check if MS MPI Launch Service (MsMpiLaunchSvc) running on all nodes.
  4. Check, that MS MPI has the rights to run R application on all the nodes on behalf of the same user, i.e. SharedUser. The user name and the password must be the same for all machines.
  5. Check, that R should be launched on behalf of the SharedUser user.
  6. Finally, execute mpiexec with the following options mentioned in Steps 7-10:

mpiexec.exe -n %1 -machinefile “C:\MachineFileDir\hosts.txt” -pwd
SharedUserPassword –wdir “\HeadMachine\SharedDir” Rscript hello.R

where

  • -wdir is a network path to the directory with shared resources.
  • –pwd is a password by SharedUser user, for example, SharedUserPassword.
  • –machinefile is a path to hosts.txt text file, for example С:\MachineFileDir\hosts.txt. hosts.txt file must be readable from the head node at the specified path and it contains a list of IP addresses of the nodes on which the R script is to be run.
  1. As a result of Step 7 MPI will log in as SharedUser with the password SharedUserPassword and execute copies of the R processes on each computer listed in the hosts.txt file.

Details

hello.R:

library(pbdMPI, quiet = TRUE)
init()
cat("Hello World from
process",comm.rank(),"of",comm.size(),"!\n")
finalize()

hosts.txt

The hosts.txt – MPI Machines File – is a text file, the lines of which contain the network names of the computers on which R scripts will be launched. In each line, after the computer name is separated by a space (for MS MPI), the number of MPI processes to be launched. Usually, it equals the number of processors in each node.

Sample of hosts.txt with three nodes having 2 processors each:

192.168.0.1 2
192.168.0.2 2
192.168.0.3 2

Leave a Comment