Sample R Jobs
Installing R Packages
While users do not have administrative permissions on the rcfcluster, R packages can still be installed into your home directory. However, some R packages have dependencies that require administrative priveleges. If you need to install one of these such packages, please send a software request to rcfsupport@groups.umass.edu
Otherwise, to install a package:
ssh rcfcluster
module load R
R
install.packages("package_name")
q()
Running R in Interactive Mode with Slurm
After logging in to rcfcluster, enter an interactive bash environment (you can add additional arguments to specify resource requests, as described in the Getting Started section):
srun --pty bash
This command will automatically log you in to the compute node that best fits your resource requests. Launch R with:
module load R
R
Submitting a Non-Interactive (Batch) Job to Slurm
Below is an example of an sbatch script that calls an Rscript:
#!/bin/bash
#SBATCH --job-name=R-example
# Log standard output & standard error to files. %j is just a placeholder for the unique slurm jobID:
#SBATCH --output=/home/username/%j.out
#SBATCH --error=/home/username/%j.err
# Resource Requests: Running 1 job ("ntasks") on a single node ("nodes") with 1 cpu dedicated to that job ("cpus-per-task").
#SBATCH --time=1:00
#SBATCH --mem=500
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mail-user=username@umass.edu
# Send email when job begins:
#SBATCH --mail-type=BEGIN
# Send email if job fails:
#SBATCH --mail-type=FAIL
# Send email when job ends successfully
#SBATCH --mail-type=END
# Load the R module in order to use R, then can use Rscript to launch job:
module load R
Rscript /home/username/myScript.R
Utilizing Batch Scripts to Submit Multiple Jobs in Parallel
While the above example demonstrates how to launch a single R job on a compute node, you will receive the most benefit by running multiple jobs in parallel (perhaps each with a different set of parameters). An example of this is provided in the Getting Started section.