Skip to content
Snippets Groups Projects
Commit ff47cdb5 authored by Jan Siwiec's avatar Jan Siwiec
Browse files

Update r.md

parent 8791fe1d
No related branches found
No related tags found
No related merge requests found
Pipeline #39652 failed
!!!warning
This page has not been updated yet. The page does not reflect the transition from PBS to Slurm.
# R # R
## Introduction ## Introduction
...@@ -42,7 +39,7 @@ $ rstudio ...@@ -42,7 +39,7 @@ $ rstudio
### Batch Execution ### Batch Execution
To run R in batch mode, write an R script, then write a bash jobscript and execute via the `qsub` command. By default, R will use 24 threads on Salomon when running MKL kernels. To run R in batch mode, write an R script, then write a bash jobscript and execute via the `sbatch` command. By default, R will use 24 threads on Salomon when running MKL kernels.
Example jobscript: Example jobscript:
...@@ -50,12 +47,12 @@ Example jobscript: ...@@ -50,12 +47,12 @@ Example jobscript:
#!/bin/bash #!/bin/bash
# change to local scratch directory # change to local scratch directory
DIR=/scratch/project/PROJECT_ID/$PBS_JOBID DIR=/scratch/project/PROJECT_ID/$SLURM_JOBID
mkdir -p "$DIR" mkdir -p "$DIR"
cd "$DIR" || exit cd "$DIR" || exit
# copy input file to scratch # copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R . cp $SLURM_SUBMIT_DIR/rscript.R .
# load R module # load R module
ml R ml R
...@@ -64,13 +61,14 @@ ml R ...@@ -64,13 +61,14 @@ ml R
R CMD BATCH rscript.R routput.out R CMD BATCH rscript.R routput.out
# copy output file to home # copy output file to home
cp routput.out $PBS_O_WORKDIR/. cp routput.out $SLURM_SUBMIT_DIR/.
#exit #exit
exit exit
``` ```
This script may be submitted directly to the PBS workload manager via the `qsub` command. The inputs are in the rscript.R file, the outputs in the routput.out file. See the single node jobscript example in the [Job execution section][1]. The inputs are in the `rscript.R` file, the outputs in the `routput.out` file.
See the single node jobscript example in the [Job execution section][1].
## Parallel R ## Parallel R
...@@ -363,23 +361,23 @@ Currently, the two packages cannot be combined for hybrid calculations. ...@@ -363,23 +361,23 @@ Currently, the two packages cannot be combined for hybrid calculations.
## Parallel Execution ## Parallel Execution
R parallel jobs are executed via the PBS queue system exactly as any other parallel jobs. The user must create an appropriate jobscript and submit it via `qsub` R parallel jobs are executed via the SLURM partition system exactly as any other parallel jobs. The user must create an appropriate jobscript and submit it via `sbatch`
An example jobscript for [static Rmpi][4] parallel R execution, running 1 process per core: An example jobscript for [static Rmpi][4] parallel R execution, running 1 process per core:
```bash ```bash
#!/bin/bash #!/bin/bash
#PBS -q qprod #SBATCH -q qprod
#PBS -N Rjob #SBATCH -N Rjob
#PBS -l select=100:ncpus=24:mpiprocs=24:ompthreads=1 #SBATCH --nodes=100 --ntasks-per-node=24 --cpus-per-task=1
# change to scratch directory # change to scratch directory
DIR=/scratch/project/PROJECT_ID/$PBS_JOBID DIR=/scratch/project/PROJECT_ID/$SLURM_JOBID
mkdir -p "$DIR" mkdir -p "$DIR"
cd "$DIR" || exit cd "$DIR" || exit
# copy input file to scratch # copy input file to scratch
cp $PBS_O_WORKDIR/rscript.R . cp $SLURM_SUBMIT_DIR/rscript.R .
# load R and openmpi module # load R and openmpi module
ml R OpenMPI ml R OpenMPI
...@@ -388,7 +386,7 @@ ml R OpenMPI ...@@ -388,7 +386,7 @@ ml R OpenMPI
mpirun -bycore -bind-to-core R --slave --no-save --no-restore -f rscript.R mpirun -bycore -bind-to-core R --slave --no-save --no-restore -f rscript.R
# copy output file to home # copy output file to home
cp routput.out $PBS_O_WORKDIR/. cp routput.out $SLURM_SUBMIT_DIR/.
#exit #exit
exit exit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment