R and Rmpi

Description

From the R Project Home Page: R is a free software environment for statistical computing and graphics. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible.

Rmpi is a package that provides MPI bindings for the R programming language. In much the same way parallel code is written in other languages such as C or Fortran, R codes can run in parallel across multiple processors or nodes.

Latest Version

  • R: 3.6.1

Installed Packages

Installed packages (with version numbers) can be listed using the commands below after loading the appropriate module file.

  • show library locations ###Note: this command is proceeded by a dot '.'
    • .libPaths()
  • list all packages installed
    • library()
  • list packages currently loaded
    • search()

Authorized Users

  • CIRCE account holders
  • RRA account holders
  • SC account holders

Platforms

  • CIRCE cluster
  • RRA cluster
  • SC cluster

Modules

Multiple versions of R are available for use on the cluster. Modules are used to load a specific version into your profile. To see which versions of R are available, use the command:

  • module avail apps/R

For Rstudio, use the following module.

  • apps/rstudio/1.0.153


Running R and Rmpi on CIRCE/SC

The R and Rmpi user guide is essential to understanding the application and making the most of it. The guide and this page should help you to get started with your simulations. Please refer to the Documentation section for a link to the guide.

  • Note on CIRCE: Make sure to run your jobs from your $WORK directory!
  • Note: Scripts are provided as examples only. Your SLURM executables, tools, and options may vary from the example below. For help on submitting jobs to the queue, see our SLURM User’s Guide.

Prepare your R Environment

Copy this file to /path/to/job/directory/.Rprofile to allow Rmpi jobs to work, e.g.:

cp /apps/R/3.6.1_el7_gcc/share/Rprofile $WORK/rmpi_test/.Rprofile

Using Rstudio

Currently, Rstudio apps/rstudio/1.0.153 with R 3.6.0 is available for use on the cluster.

In order to use Rstudio via X2Go: you will first need to start a SLURM Interactive Session session, and then properly configure your DISPLAY environment variable as shown below:

[user@itn0 ~]$ echo $DISPLAY
:158.0
[user@itn0 ~]$ export DISPLAY=$(hostname)$DISPLAY
[user@itn0 ~]$ echo $DISPLAY
itn0.rc.usf.edu:158.0
[user@itn0 ~]$ srun --time=24:00:00 --mem=16384 --nodes=1 --ntasks-per-node=8 --pty /bin/bash
[user@svc-3024-9-24 ~]$ module purge
[user@svc-3024-9-24 ~]$ module load apps/rstudio/1.0.153
[user@svc-3024-9-24 ~]$ rstudio

This will get start a session with 8 cpu cores on a single node with 16 GB of shared memory for 24 hours, and allow you to use the Rstudio interface.

  • NOTE: When running RStudio via X2Go, you will need to change the font to be compatible with your X2Go session. To do so, click "Tools --> Options --> Appearance", and under "Editor Font", select "Liberation Mono".

Submitting a Job

A sample submit script is listed below. If, for example, you have an R input file named r-test.R, you would set up a submit script like this:

  • The script below (for testing, name it “r-test.sh”) can be copied into your job directory (the folder with your input files) and modified so that you can submit batch processes to the queue.
  • Note: Rmpi is not available in all versions of R on CIRCE, but is compiled with R versions 3.1.2, 3.4.2, 3.5.0, and 3.6.0 (among others).

#!/bin/bash
#
#SBATCH --comment=r-test
#SBATCH --ntasks=4
#SBATCH --job-name=r-test
#SBATCH --output=output.%j.r-test
#SBATCH --time=01:00:00

#### SLURM 4 processor R test to run for 1 hour.

module purge
module add apps/R/3.6.1_el7_gcc

mpirun Rscript r-test.R

 
Next, you can change to your job’s directory, and run the sbatch command to submit the job:

[user@login0 ~]$ cd my/jobdir
[user@login0 jobdir]$ sbatch ./r-test.sh
  • You can view the status of your job with the “squeue -u <username>” command

Documentation

Home Page, User Guides, and Manuals

Benchmarks, Known Tests, Examples, Tutorials, and Other Resources

More Job Information

See the following for more detailed job submission information:

Reporting Bugs

Report bugs with R and Rmpi to the IT Help Desk: rc-help@usf.edu