General

R is a free software environment for statistical computing and graphics. It is a modular code interpreter and can be extended via packages from the Comprehensive R Archive Network (CRAN).

Recommended read for all R users for an overview of R's HPC related packages grouped by topic: CRAN Task View: High-Performance and Parallel Computing with R

Modules providing R

Modules providing R can be found via

module spider R

The "*-cf" versions are actually a conda environments but without any conda functionality exposed to the user. The packages are from the popular conda-forge repository and it is optimized for haswell ( –mtune=haswell  ) processors, which is also suitable for Zen3 AMD processors. In addition all BLAS and LAPACK calls are handled by optimized Intel MKL libraries ( v2023.2.1 ).

For details regarding compilations flags, see $R_HOME/etc/Makeconf after loading the module.

Loading the module
module load R/4.3.3

This module also does a bit more work under the hood. It sets the following environment variables :

  1. R_LIBS_USER=/hpc/gpfs2/scratch/u/$USER/.R/4.3 , so that users may install additional CRAN packages themselves or override existing packages with different versions. The directory will be created automatically by the module.
  2. TMPDIR=/hpc/gpfs2/scratch/u/$USER/.Rtmp/4.3 , so that users temporary files don't accumulate or fill up the global /tmp folder on the login nodes. The directory will be created automatically by the module.
  3. OMP_NUM_THREADS=1 , so that implicit multithreading via OpenMP threading is disabled by default. If this variable would be unset, then each R process might use as much threads (typically 128) as available on a node, even if less is requested/allocated. If R is then parallelized via process forking ( parallel package) , then the nodes could get easily overloaded.
  4. various other environment variables needed for dependencies.

Installed packages

package (case insensitive)R/4.3.3-cf
abind1.4-5
acepack1.4.2
ade41.7-22
adehabitatHR0.4.21
adehabitatLT0.3.27
adehabitatMA0.3.16
AER1.2-12
alphavantager0.1.3
Amelia1.8.2
anytime0.3.9
ape5.8
aplot0.2.3
arrow16.1.0
askpass1.2.0
assertthat0.2.1
aTSA3.1.2.1
backports1.5.0
base64enc0.1-3
base64url1.4
BatchJobs1.9
batchtools0.9.17
bayesm3.1-6
bayestestR0.13.2
BBmisc1.13
bdsmatrix1.3-7
bench1.1.3
BH1.84.0-0
bigmemory4.6.4
bigmemory.sri0.1.8
bindr0.1.1
bindrcpp0.2.3
binom1.1-1.1
BiocManager1.30.23
BiocVersion3.18.1
biomod24.2-5-2
bit4.0.5
bit644.0.5
bitops1.0-7
blob1.2.4
bookdown0.40
brew1.0-10
brio1.1.5
broom1.0.6
bslib0.7.0
cachem1.1.0
callr3.7.6
car3.1-2
carData3.0-5
caret6.0-94
carfima2.0.2
caTools1.18.2
cba0.2-24
cellranger1.1.0
checkmate2.3.1
chk0.9.2
chron2.3-61
CircStats0.2-6
classInt0.4-10
cli3.6.3
cliapp0.1.2
climdex.pcic1.1-11
ClimProjDiags0.3.3
clipr0.8.0
clock0.7.0
cmprsk2.2-12
coda0.19-4.1
colorspace2.1-0
common1.1.3
commonmark1.9.1
conflicted1.2.0
conquer1.3.3
corpcor1.6.10
covr3.6.4
cpp110.4.7
crayon1.5.3
credentials2.0.1
crosstalk1.2.1
crul1.4.2
cubature2.0.4.6
curl5.2.1
cvar0.5
CVST0.2-3
DALEX2.4.3
data.table1.15.4
data.tree1.1.0
datawizard0.12.0
date1.2-42
DBI1.2.3
DBItest1.7.3
dbplyr2.5.0
ddalpha1.3.15
decor1.0.2
deldir2.0-4
DEoptim2.2-8
DEoptimR1.1-3
desc1.4.3
deSolve1.40
devtools2.4.5
diagram1.6.5
DiagrammeR1.0.11
dials1.2.1
DiceDesign1.10
dichromat2.0-0.1
diffobj0.3.5
digest0.6.36
dimRed0.2.6
dismo1.3-14
docopt0.7.1
doFuture1.0.1
doMC1.3.8
doMPI0.2.2
doParallel1.0.17
doSNOW1.0.20
dotCall641.1-1
downlit0.4.4
downloader0.4
dplyr1.1.4
dqrng0.3.2
DRR0.0.4
DT0.33
dtplyr1.3.1
dygraphs1.1.1.6
dynlm0.3-6
e10711.7-14
earth5.3.3
easyNCDF0.1.2
ecodist2.1.3
ECOSolveR0.5.5
ecospat4.1.1
effects4.2-2
effectsize0.8.9
ei1.3-3
eiPack0.2-2
ellipse0.5.0
ellipsis0.3.2
energy1.7-11
estimability1.5
evaluate0.24.0
evd2.3-7
expm0.999-9
fansi1.0.6
farver2.1.2
fAssets4023.85
fastDummies1.7.3
fastICA1.2-4
fastmap1.2.0
fastmatch1.1-4
fasttime1.1-0
fBasics4032.96
fCopulae4022.85
fExtremes4032.84
fGarch4033.92
fields15.2
filehash2.4-6
FKF0.2.5
FKF.SP0.3.1
float0.3-2
fMultivar4031.84
FNN1.1.4
fontawesome0.5.2
fontBitstreamVera0.1.1
fontLiberation0.1.0
fontquiver0.2.1
forcats1.0.0
foreach1.5.2
forecast8.23.0
formatR1.14
Formula1.2-5
fracdiff1.5-3
fs1.6.4
fts0.9.9.2
furrr0.3.1
future1.33.2
future.apply1.11.2
future.batchtools0.12.1
future.callr0.8.2
gam1.22-3
gargle1.5.2
gbm2.1.9
gbRd0.4.12
gbutils0.5
gdata3.0.0
geepack1.3.11
generics0.1.3
geometry0.4.7
geoR1.9-4
geosphere1.5-18
gert2.0.1
ggforce0.4.2
ggfun0.1.5
ggplot23.5.1
ggplotify0.1.2
ggraph2.1.0
ggrepel0.9.5
ggtree3.10.1
gh1.4.1
gistr0.9.0
gitcreds0.1.2
glmnet4.1-8
globals0.16.3
glue1.7.0
gmm1.8
gmodels2.19.1
gmp0.7-4
goftest1.2-3
googledrive2.1.1
googlesheets41.1.1
gower1.0.1
GPfit1.0-8
gplots3.1.3.1
graphlayouts1.1.0
gridExtra2.3
gridGraphics0.5-1
gsl2.1-8
gss2.2-7
gtable0.3.5
gtools3.9.5
h2o3.44.0.3
hardhat1.4.0
haven2.5.4
hdf5r1.3.10
here1.0.1
hexbin1.28.3
highr0.11
Hmisc5.1-3
hms1.1.3
htmlTable2.4.2
htmltools0.5.8.1
htmlwidgets1.6.4
httpcode0.3.0
httpuv1.6.15
httr1.4.7
httr21.0.1
iBreakDown2.1.2
ids1.0.1
igraph2.0.3
infer1.0.7
influenceR0.1.5
ingredients2.3.0
ini0.3.1
insight0.20.2
interp1.1-6
invgamma1.1
ipred0.9-14
IRdisplay1.1
IRkernel1.3.2
irlba2.3.5.1
Iso0.0-21
isoband0.2.7
iterators1.0.14
jpeg0.1-10
jquerylib0.1.4
jsonlite1.8.8
kernelshap0.6.0
kernlab0.9-32
knitr1.48
ks1.14.2
labeling0.4.3
lambda.r1.2.4
LaplacesDemon16.1.6
later1.3.2
latticeExtra0.6-30
lava1.7.3
lazyeval0.2.2
leaps3.2
lgr0.4.4
lhs1.2.0
lifecycle1.0.4
linprog0.9-4
listenv0.9.1
littler0.3.20
lme41.1-35.5
lmerTest3.1-3
lmtest0.9-40
lobstr1.1.2
locfit1.5-9.9
logcondens2.1.8
logr1.3.8
lpSolve5.6.20
lubridate1.9.3
lwgeom0.2-14
magic1.6-1
magrittr2.0.3
mapdata2.3.1
mapproj1.2.11
maps3.4.2
maptools1.1-8
markdown1.13
Matching4.10-14
MatchIt4.5.5
mathjaxr1.6-0
matrixcalc1.0-6
MatrixModels0.5-3
matrixStats1.3.0
maxLik1.5-2.1
maxnet0.1.4
mclust6.1.1
mcmc0.9-8
MCMCglmm2.36
MCMCpack1.7-0
mda0.5-4
memoise2.0.1
Metrics0.1.4
mets1.3.3
mime0.12
miniUI0.1.1.1
minqa1.2.7
misc3d0.9-1
miscTools0.6-28
mitools2.4
mlbench2.1-5
MLmetrics1.1.3
mlr30.20.0
mlr3measures0.5.0
mlr3misc0.15.1
mnormt2.1.1
MNP3.1-5
mockery0.4.4
mockr0.2.1
mockthat0.2.8
modeldata1.4.0
modelenv0.1.1
ModelMetrics1.2.2.2
modelr0.1.11
msm1.7.1
multcomp1.4-25
multiApply2.1.4
multicool1.0.1
munsell0.5.1
mvnormtest0.1-9-3
mvtnorm1.2-5
nabor0.5.0
ncdf41.22
ncdf4.helpers0.3-6
nloptr2.0.3
NLP0.2-1
nortest1.0-4
numDeriv2016.8-1.1
openssl2.2.0
openxlsx4.2.5.2
padr0.6.2
palmerpenguins0.1.1
paradox1.0.1
parallelly1.37.1
parallelMap1.5.1
parameters0.22.0
parsnip1.2.1
pastecs1.4.2
patchwork1.2.0
pbdMPI0.5-1
pbdZMQ0.3-11
pbkrtest0.5.2
pbmcapply1.5.1
PCICt0.5-4.4
pec2023.04.12
performance0.12.0
PerformanceAnalytics2.0.4
permute0.9-7
pillar1.9.0
pixmap0.4-13
pkgbuild1.4.4
pkgconfig2.0.3
pkgdown2.1.0
pkgKitten0.2.3
pkgload1.3.4
plogr0.2.0
plot3D1.4.1
plotly4.10.4
plotmo3.6.3
plotrix3.8-4
pls2.8-3
plyr1.8.9
png0.1-8
poibin1.5
polspline1.1.25
polyclip1.10-6
pracma2.4.4
praise1.0.0
PresenceAbsence1.1.11
prettycode1.1.0
prettyunits1.2.0
pROC1.18.5
processx3.8.4
prodlim2024.06.25
profmem0.6.0
profvis0.3.8
progress1.2.3
progressr0.14.0
promises1.3.0
proxy0.4-27
PRROC1.3.1
pryr0.1.6
ps1.7.7
pscl1.5.9
psy1.2
Publish2023.01.17
purrr1.0.2
qtl1.66
quadprog1.5-8
Quandl2.11.0
quantmod0.4.26
quantreg5.98
R.methodsS31.8.2
R.oo1.26.0
R.utils2.12.3
R62.5.1
ragg1.3.2
RandomFields3.3.14
RandomFieldsUtils1.2.5
randomForest4.7-1.1
randomForestSRC3.3.0
ranger0.16.0
RANN2.6.1
rappdirs0.3.3
raster3.6-26
rbibutils2.2.16
rbokeh0.5.2
rcmdcheck1.4.0
RcmdrMisc2.9-1
RColorBrewer1.1-3
Rcpp1.0.12
RcppAnnoy0.0.22
RcppArmadillo14.0.0-1
RcppEigen0.3.4.0.0
RcppParallel5.1.6
RcppProgress0.4.2
RcppRoll0.3.1
RcppTOML0.2.2
RCurl1.98-1.16
Rdpack2.6
readr2.1.5
readstata130.10.1
readxl1.4.3
recipes1.1.0
relimp1.0-5
rematch2.0.0
rematch22.1.2
remotes2.5.0
repr1.1.7
reprex2.1.1
reshape0.8.9
reshape21.4.4
reticulate1.38.0
rex1.2.1
rgdal1.6-7
rgenoud5.9-0.10
rgexf0.16.3
rgl1.3.1
Rglpk0.6-5.1
RhpcBLASctl0.23-42
riingo0.3.1
rio1.1.1
riskRegression2023.12.21
rlang1.1.4
rlist0.4.6.2
RLRsim3.1-8
rmarkdown2.27
Rmpi0.7-2
rms6.8-1
RMySQL0.10.27
rneos0.4-0
RNetCDF2.9-2
robustbase0.99-3
ROCR1.0-11
RODBC1.3-23
roxygen27.3.2
RPostgreSQL0.7-6
rprojroot2.0.4
rsample1.2.1
rslurm0.6.2
Rsolnp1.16
RSpectra0.16-1
RSQLite2.3.4
rstudioapi0.16.0
RUnit0.4.33
rversions2.1.2
rvest1.0.4
s21.1.6
sandwich3.1-0
sass0.4.9
scales1.3.0
selectr0.4-2
sendmailR1.4-0
servr0.30
sessioninfo1.2.2
setRNG2024.2-1
sf1.0-16
sfsmisc1.1-18
shape1.4.6.1
shiny1.8.1.1
simr1.0.7
sitmo2.0.2
slam0.1-50
slider0.3.1
sm2.2-6.0
sn2.1.1
snow0.4-4
SnowballC0.7.1
snowfall1.84-6.3
sodium1.3.1
sourcetools0.1.7-1
sp2.1-4
spam2.10-0
SparseM1.84
spatstat3.0-7
spatstat.core2.4-4
spatstat.data3.1-2
spatstat.explore3.2-6
spatstat.geom3.2-9
spatstat.linnet3.1-4
spatstat.model3.2-10
spatstat.random3.2-3
spatstat.sparse3.1-0
spatstat.utils3.0-5
spData2.3.1
spdep1.3-5
splancs2.01-45
splines20.5.3
SQUAREM2021.1
stabledist0.7-1
statmod1.5.0
stringdist0.9.12
stringi1.8.4
stringr1.5.1
strucchange1.5-3
SuppDists1.1-9.7
survex1.2.0
survey4.4-2
svglite2.1.3
sys3.4.2
systemfit1.1-30
systemfonts1.1.0
tcltk21.2-11
TeachingDemos2.13
tensor1.5
tensorA0.36.2.1
terra1.7-78
testit0.13
testthat3.2.1.1
textshaping0.4.0
TH.data1.1-2
this.path2.5.0
tibble3.2.1
tidygraph1.3.0
tidymodels1.2.0
tidyquant1.0.7
tidyr1.3.1
tidyselect1.2.1
tidytree0.4.6
tidyverse2.0.0
timechange0.3.0
timeDate4032.109
timereg2.0.5
timeSeries4032.109
timetk2.9.0
tinytex0.51
tkrplot0.0-27
tm0.7-13
tmvnsim1.0-2
tmvtnorm1.6
treeio1.26.0
triebeard0.4.1
truncdist1.0-2
truncnorm1.0-9
TSA1.3.1
tseries0.10-56
tsfeatures1.1.1
TTR0.24.4
tune1.2.1
tweenr2.0.3
tzdb0.4.0
ucminf1.2.2
units0.8-5
urca1.3-4
urlchecker1.0.1
urltools1.7.3
usethis2.2.3
utf81.2.4
uuid1.2-0
uwot0.1.16
vcd1.4-12
vctrs0.6.5
vdiffr1.0.7
vegan2.6-6.1
VGAM1.1-11
viridis0.6.5
viridisLite0.4.2
visNetwork2.1.2
vroom1.6.5
waldo0.5.2
warp0.2.1
webutils1.2.0
WhatIf1.5-10
whisker0.4.1
withr3.0.0
wk0.9.2
wkutils0.1.3
workflows1.1.4
workflowsets1.1.0
writexl1.5.0
xfun0.45
xgboost2.0.3.1
XML3.99-0.17
xml21.3.6
xopen1.0.1
xtable1.8-4
xts0.14.0
yaml2.3.9
yardstick1.3.1
yulab.utils0.1.4
zeallot0.1.0
zip2.3.1
zoo1.8-12



Installing additional packages

Ticket via HPC-Service

This is the preferred method if the module in question has been published on CRAN, since the package will be available to everyone using the available R modules. For more information on how to open a Ticket see Service and Support.

Self service

The R modules set R_LIBS_USER  to a directory in your scratch area, e.g. /hpc/gpfs2/scratch/u/$USER/.R/4.3  , where packages will be installed. This typically works well unless your package requires dependencies like additional libraries. In this case (the installation will fail) open a Ticket!

CRAN packages are case sensitive!


via install.packages
install.packages("BlA")
via BiocManager::install
BiocManager::install("BlA")

Packages installed by Users (located in R_LIBS_USER)  will always be preferred. If you require a newer (or different) version of a package that is already installed centrally, you can just install it yourself.


Performance considerations and common Pitfalls

Implicit multithreading

R is able to use implicit multithreading using a subset of optimized functions or functions taking advantage of parallelized BLAS/LAPACK routines. This is controlled by the environment variable OMP_NUM_THREADS which is set to 1 by default. If you know your code benefits from this, then you can increase it manually either within R or by changing the environment variable explicitly (and/or reducing the number of worker or MPI processes at the same time). Running benchmarks is mandatory when using this and don't expect miracles.

Using parallel::detectCores() 

This will detect the number of CPU cores of the entire Compute-Node (typically 128), irrespective of the number of cores you requested via Slurm. When Slurm has allocated less than a full node for your job, this will lead to Node overloading (spawning more threads/processes than CPU cores allocated) and consequently inefficient Jobs. Therefore, do not use parallel::detectCores()at all on HPC clusters, always use either parallelly::availableCores() or future::availableCores()to determine the correct number of cores available in single-Node Jobs.

ncpus <- parallelly::availableCores()
options(mc.cores = ncpus) # set a global option for parallel packages
res<-mclapply(... ,mc.cores = ncpus)) # or set the number of cores per call

Poor scaling of parallel code

Don't expect your code to work well automatically if you just scale up the numer of CPU cores. The Job effeciency often drops with increasing amount of CPU cores and in some cases it may take even longer when using too much CPU cores.

Beware submitting large R jobs

Before you start submitting large jobs to the cluster, measure the parallel efficiency first. Parallel efficiency (actual scaling vs. ideal scaling) should be well above 50%! Failure to do so may result in official warnings and in extreme and repetitive cases to account suspension.

R is using more threads than CPU cores available

This is a common problem as setting OMP_NUM_THREADS=1 is no silver bullet to catch them all. Some R packages do not respect it and still launch 128 threads per process. Packages known for this behaviour:

packagesolution
rangeradd export R_RANGER_NUM_THREADS=1 to your Slurm script after loadthing the R module. Details.
randomForestSRCadd export MC_CORES=1 and export RF_CORES=1 to your Slurm script after loadthing the R module. Details.

If you encoutner a similar problem with other packages and you know the solution, let is know so that everyone can benefit by adding it to the list above.

Installing packages in a Job does not work

This is to be excepted when installing from sources that require internet access, which the compute nodes don't have. In general it is a bad idea to install packages from a production computation. Instead, install packages either interactively oder via an R-script on the login node. Due to the GPFS, the package will be available on all compute nodes immediately.

MPI with R and Slurm

Do not use MPI with R unless you have to. This might only be the case when 128 cores are not enough.

There are several packages that allow for MPI parallelization with R:

  • Rmpi (package that implements the low level MPI interface)
  • pbdMPI (S4 classes to directly interface MPI in order to support the Single Program/Multiple Data (SPMD) parallel programming style)
  • doMPI (high level package that enhances foreach with MPI, uses all requested CPU cores excluding the control process. E.g. if you request 16 MPI process, only 15 of them will be able to do the heavy lifting.)

There is one important caveat in using R with Slurm (mandatory): since Slurm is taking care of spawning MPI processes (requested processes are running throughout the lifetime of your Slurm Job), you cannot spawn the processes by yourself or dynamically by calling any of the mpi.spawn.* functions . 


Private installations

Almost always there is no need for private installations. If you still think you need one, continue reading.

From conda-forge

Most R packages available on CRAN are also available via conda-forge. In fact, we use conda-forge for centrally managed R installations as well.

module load micromamba
micromamba create -n myspecialRenv -c conda-forge r-base==4.3.3 ...
micromamba activate myspecialRenv
micromamba install -c conda-forge r-morepackages

Self compilation

Although not recommended or supported, you may simply compile R yourself by loading an appropriate compiler module. You will have to manage dependencies yourself though.


Slurm Job templates

Single node Jobs (forking, threading)
#!/bin/bash
#SBATCH --time=00:20:00
#SBATCH --partition=epyc
#SBATCH --tasks=1
#SBATCH --cpus-per-task=16
#SBATCH --mem-per-cpu=2G

# Load the version of R you want to use
module purge
module load R

# Run your R script
srun Rscript test.R


MPI Jobs
#!/bin/bash
#SBATCH --time=00:20:00
#SBATCH --partition=epyc
#SBATCH --tasks-per-node=16
#SBATCH --nodes=2
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=2G

# Load the version of R you want to use
module purge
module load R

# Run your R script
srun Rscript test.R



  • Keine Stichwörter