5 Libraries and Environment Modules

5.1 Introduction

Environment modules are needed to make certain libraries (e.g. R) available across all nodes in the cluster.

Environment variables are installed and maintained via Spack.

Please note that RStudio Workbench is decoupled from Slurm. Everything which should be run on the nodes via Slurm requires to have the respective environment modules loaded in the Slurm template file whereas if you run something in RStudio Workbench, the libraries installed in the underlying Ubuntu 20.04 container will be used.

The following part only deals with the Spack configuration side as everything in the container should just work (with respect to R).

Available env modules can be queried in the terminal via modules avail.

To be able to load modules, put the following at the top of your ~/.bashrc file:

export SPACK_ROOT=/opt/spack
. $SPACK_ROOT/share/spack/setup-env.sh

export MODULEPATH=/opt/spack/share/spack/modules/linux-centos7-x86_64

(The export of the MODULEPATH env var should actually be done by the spack setup script but failed in the past for some users. Adding it manually should do no harm.)

Here is a sample output of module avail:

------------------------- /opt/spack/share/spack/modules/linux-centos7-x86_64 --------------------------
   byobu-5.127-gcc-9.2.0-by2qc2g          (L)    python-3.7.4-gcc-9.2.0-nbjbfzi     (L)
   ccache-3.3.4-gcc-9.2.0-v3xzqqh         (L)    r-3.5.2-gcc-9.2.0-oxo76vo
   curl-7.63.0-gcc-9.2.0-cq4w37y          (L)    r-3.6.1-gcc-9.2.0-j25wr6z
   fish-3.0.0-gcc-9.2.0-gdyab6r      

5.2 Loading modules

Modules can be loaded via module load <module>.

First, a C compiler need to be loaded as most other libraries depend on it.

module load gcc-9.2.0-gcc-4.8.5-wqdecm4

Next, load all libraries your analysis/R packages need, for example GDAL, PROJ, etc.

You should load the modules both within ~/.bashrc and within your SLURM template.