R Packages/Libraries
Overview
This page details some of the common issues to be aware of when transitioning from using R on a desktop, to using R on the HPC cluster.
The child pages here are the only packages/libraries we have documented, but many more exist.
Installing Packages and General Issues
Installing Packages: General
Any version of R that you are using will be installed in a system folder that you will not have permissions to write into.
When you come to installing your own packages, you will typically be presented with a ‘lib =”…” is not writable. Would you like to use a personal library instead?
’ message. See below for an example:
This is perfectly fine and not to be worried about.
By default, R will install packages in the user’s home under the R folder, via the compiler/architecture the version of R was build using, and then by the version of R itself.
The example below demonstrates packages installed specifically using the standard gcc linux build of version 4.0, as well as an intel version of R 3.6.
[]$ cd ~
[~]$ ls R
intel x86_64-conda_cos6-linux-gnu-library x86_64-pc-linux-gnu-library
[~]$ ls R/x86_64-pc-linux-gnu-library/
3.5 3.6 4.0
[~]$ ls R/x86_64-pc-linux-gnu-library/4.0/
annotate Biostrings CNVRG digest GenomeInfoDb gtable lattice motifmatchr prettyunits RcppProgress rtracklayer TFMPvalue withr
AnnotationDbi BSgenome codetools DirichletMultinomial GenomeInfoDbData inline lifecycle munsell processx Rhtslib Rtsne tibble xfun
...
[~]$ ls R/intel/3.6/
abind callr curl ellipsis ggrepel htmlwidgets lifecycle minqa packrat processx readr Rtsne StanHeaders vctrs zeallot
askpass car data.table emmeans ggridges httpuv listenv mitools parameters progress readxl scales stringi vegan zip
...
Installing Packages: Bus error: cc1plus error
If while installing a package you come across an error of the form:
“internal compiler error: Bus error (program cc1plus)”
then it means you do not have enough memory allocated in your session.
If you are using an interactive session (e.g. from an salloc
call), then exit this session and create a new one that requests more memory.
If you are installing using a session on one of the login nodes, then please notify us (using arcc-help@uwyo.edu) as this typically means another user is running something that is using the majority of the available memory on that login node.
Conflicting libPaths
We have a version of R4.0.5 that comes packaged with 100s of pre-installed libraries. The core idea of this version of R is to provide a self contained eco-system - but obviously it does not provide ALL libraries and in cases an individual will need to use a library not provided. Users can still install additional libraries into their home folder. As with any complex system of libraries with trees of dependencies and conflicting versions, there can be issues.
One issue that we are aware of is when users have conflicting versions of libraries stored in the home folder folder overriding those installed with R.
For example, I have library CLI 2.3.1 installed in /home/salexan5/R/x86_64-pc-linux-gnu-library/4.0/cli/
, which conflicts with version 2.4.0 installed in /apps/u/gcc/7.3.0/r/4.0.5-bqwhj7g/rlib/R/library/
So, first attempt, it looks in /home/salexan5/R/x86_64-pc-linux-gnu-library/4.0/cli/
since this is first in the list of library paths to look in:
[salexan5@tlog2 ~]$ module load gcc/7.3.0 r/4.0.5-py27
[salexan5@tlog2 ~]$ R
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
...
> .libPaths()
[1] "/pfs/tc1/home/salexan5/R/x86_64-pc-linux-gnu-library/4.0"
[2] "/pfs/tc1/apps/el7-x86_64/u/gcc/7.3.0/r/4.0.5-bqwhj7g/rlib/R/library"
> library(devtools)
Loading required package: usethis
Error: package or namespace load failed for ‘devtools’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘cli’ 2.3.1 is being loaded, but >= 2.4.0 is required
> quit()
Second attempt, I swap these over so it’ll first look in /apps/el7-x86_64/u/gcc/7.3.0/r/4.0.5-bqwhj7g/rlib/R/library
which contains the appropriate version:
Installing labdsv
Trying to install install.packages("labdsv")
resulted in the following error:
This appears to be a reasonably common problem:
and is essentially a result of conflicts between compilers when using complex data types with the workaround of disabling the diagnostic error.
To resolve the issue, create and/or update the ~/.R/Makevars
file by adding the following lines:
Installing rjags
The first step will be to module load
the version of jags
, and then use the following install.packages
command with an example of the output you’ll see:
Teton: R and Intel/MKL
On Teton we have versions of r (3.6.1/4.0.2) built with the Intel compiler and related MKL (Maths Kernel Library) that follows a request relating to Improving R Performance by installing optimized BLAS/LAPACK libraries. To use:
The Intel built version is dependent on the following modules core:
intel/18.0.1
intel-mkl/2018.2.199
The
module load r/*.*.*-intel
line will automatically load these modules for you.
Installing Packages to Use with Intel Version
The packages that you have installed for the standard versions of R will not work for the Intel version since they are built with different compilers. This means you will need to re-install the packages that you use.
If you potentially want to use both versions then you will need to create a second folder to install the Intel versions into.
This has been tested with R.3.6.1 intel version - a similar approach should apply for 4.0
On Teton, R packages are typically installed into:
One way to install the Intel packages is the following:
Create a folder
~/R/intel/3.6/
Use
module load r/3.6.1-intel
to load the Intel version.After starting R, use
.libPaths(c("~/R/intel/3.6/"))
to set your environment to use this folder.If you run
.libPaths()
you should see something of the form:
Install packages as normal e.g.
install.packages("<the package's name>")
When running your R scripts you need to set
.libPaths(c("~/R/intel/3.6/"))
before loading any libraries to inform R where the appropriate packages can be found.Note: Currently R Package: RStan can not be installed using the intel version.