...
An example of how to install Rmpi
using the module openmpi/gcc/64/1.10.7
can be found below. Note that, the package snow
has to be installed as well.
Code Block | ||
---|---|---|
| ||
module load r/4.2.1 module load openmpi/gcc/64/4.1.10.74 R .libPaths("~/rlibs") # assuming you are installing your # packages at the ~/rlibs folder install.packages("Rmpi", lib = "~/rlibs", repo = "https://cloud.r-project.org/", configure.args = "--with-mpi=/gpfs/cm/sharedsharedfs1/admin/hpc2.0/apps/openmpi/gcc/64/4.1.10.74/") install.packages("snow", lib = "~/rlibs", repo = "https://cloud.r-project.org/") |
...
Code Block |
---|
#!/bin/bash #SBATCH -p general #SBATCH -n 30 source /etc/profile.d/modules.sh module purge module load r/4.2.1 mpi/openmpi/gcc/64/4.1.10.74 # If MPI tells you that forking is bad uncomment the line below # export OMPI_MCA_mpi_warn_on_fork=0 Rscript mpi.R |
Now create the mpi.R
script:
Code Block | ||
---|---|---|
| ||
library(parallel) .libPaths("~/rlibs") hello_world <- function() { ## Print the hostname and MPI worker rank. paste(Sys.info()["nodename"],Rmpi::mpi.comm.rank(), sep = ":") } cl <- makeCluster(Sys.getenv()["SLURM_NTASKS"], type = "MPI") clusterCall(cl, hello_world) stopCluster(cl) |
...