Accessing software
Overview
Teaching: 30 min
Exercises: 15 minQuestions
How do we load and unload software packages?
Objectives
Understand how to load and use a software package.
On a high-performance computing system, it is seldom the case that the software we want to use is available when we log in. It is installed, but we will need to “load” it before it can run.
Before we start using individual software packages, however, we should understand the reasoning behind this approach. The three biggest factors are:
- software incompatibilities
- versioning
- dependencies
Software incompatibility is a major headache for programmers. Sometimes the presence (or absence) of
a software package will break others that depend on it. Two of the most famous examples are Python 2
and 3 and C compiler versions. Python 3 famously provides a python
command that conflicts with
that provided by Python 2. Software compiled against a newer version of the C libraries and then
used when they are not present will result in a nasty 'GLIBCXX_3.4.20' not found
error, for
instance.
Software versioning is another common issue. A team might depend on a certain package version for their research project - if the software version was to change (for instance, if a package was updated), it might affect their results. Having access to multiple software versions allow a set of researchers to prevent software versioning issues from affecting their results.
Dependencies are where a particular software package (or even a particular version) depends on having access to another software package (or even a particular version of another software package). For example, the VASP materials science software may depend on having a particular version of the FFTW (Fastest Fourier Transform in the West) software library available for it to work.
Environment modules
Environment modules are the solution to these problems. A module is a self-contained description of a software package - it contains the settings required to run a software package and, usually, encodes required dependencies on other software packages.
There are a number of different environment module implementations commonly
used on HPC systems: the two most common are TCL modules and Lmod. Both of
these use similar syntax and the concepts are the same so learning to use one will
allow you to use whichever is installed on the system you are using. In both
implementations the module
command is used to interact with environment modules. An
additional subcommand is usually added to the command to specify what you want to do. For a list
of subcommands you can use module -h
or module help
. As for all commands, you can
access the full help on the man pages with man module
.
On login you may start out with a default set of modules loaded or you may start out with an empty environment; this depends on the setup of the system you are using.
Listing available modules
To see available software modules, use module avail
[nsid@platolgn01 ~]$ module avail
[Some output removed for clarity]
------------------------------- MPI-dependent avx2 modules -------------------------------
abyss/2.1.5 (bio) neuron/8.0.0 (bio,D)
abyss/2.2.5 (bio,D) opencarp/4.0
adol-c/2.7.2 opencascade/7.5.2 (D)
alpscore/2.2.0 (phys,D) opencoarrays/2.9.2
amber/18.14-18.17 (chem) openfoam-extend/4.1 (phys)
amber/20.9-20.15 (chem) openfoam/v2006 (phys)
amber/20.12-20.15 (chem,D) openfoam/v2012 (phys)
ambertools/20 openfoam/v2112 (phys)
ambertools/21 openfoam/v2206 (phys)
ambertools/23 (D) openfoam/v2212 (phys)
apbs/1.3 (chem) openfoam/v2306 (phys)
arpack-ng/3.9.0 (math,D) openfoam/8 (phys)
aspect/2.3.0 openfoam/9 (phys)
aspect/2.4.0 (D) openfoam/10 (phys)
astrid/2.2.1 openfoam/11 (phys,D)
blacs/1.1 (math) openmc/0.13.2
boost-mpi/1.72.0 (t) openmc/0.13.3 (D)
boost-mpi/1.80.0 (t,D) openmm-alphafold/7.5.1
cantera/2.4.0 (chem) openmm/7.5.0 (chem)
cantera/2.5.1 (chem) openmm/7.7.0 (chem)
cantera/2.6.0 (chem,D) openmm/8.0.0 (chem,D)
cdo/1.9.8 (geo) opensees/3.2.0
cdo/2.0.4 (geo) opensees/3.5.0 (D)
cdo/2.0.5 (geo) orca/4.2.1 (chem)
cdo/2.2.1 (geo,D) p4est/2.2 (math)
cgns/3.4.1 (phys) p4est/2.3.2 (math)
cgns/4.1.0 (phys) p4est/2.8.5 (math,D)
cgns/4.1.2 (phys,D) paraview-offscreen-gpu/5.8.0 (vis)
cp2k/8.2 (chem) paraview-offscreen-gpu/5.9.1 (vis)
[Most output removed for clarity]
Where:
S: Module is Sticky, requires --force to unload or purge
bio: Bioinformatic libraries/apps / Logiciels de bioinformatique
m: MPI implementations / Implémentations MPI
math: Mathematical libraries / Bibliothèques mathématiques
L: Module is loaded
io: Input/output software / Logiciel d'écriture/lecture
t: Tools for development / Outils de développement
vis: Visualisation software / Logiciels de visualisation
chem: Chemistry libraries/apps / Logiciels de chimie
geo: Geography libraries/apps / Logiciels de géographie
phys: Physics libraries/apps / Logiciels de physique
Aliases: Aliases exist: foo/1.2.3 (1.2) means that "module load foo/1.2" will load foo/1.2.3
D: Default Module
If the avail list is too long consider trying:
"module --default avail" or "ml -d av" to just list the default modules.
"module overview" or "ml ov" to display the number of modules for each name.
Use "module spider" to find all possible modules and extensions.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
Listing currently loaded modules
You can use the module list
command to see which modules you currently have loaded
in your environment. If you have no modules loaded, you will see a message telling you
so
[nsid@platolgn01 ~]$ module list
Currently Loaded Modules:
1) CCconfig 4) imkl/2020.1.217 (math) 7) libfabric/1.10.1
2) gentoo/2020 (S) 5) intel/2020.1.217 (t) 8) openmpi/4.0.3 (m)
3) gcccore/.9.3.0 (H) 6) ucx/1.8.0 9) StdEnv/2020 (S)
[Some output removed for clarity]
Loading and unloading software
To load a software module, use module load
.
In this example we will use R, a software environment for statistics.
Initially, R is not loaded.
We can test this by using the which
command.
which
looks for programs the same way that Bash does,
so we can use it to tell us where a particular piece of software is stored.
[nsid@platolgn01 ~]$ which R
/usr/bin/which: no R in (/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Compiler/intel2020/openmpi/4.0.3/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/libfabric/1.10.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/ucx/1.8.0/bin:/cvmfs/restricted.computecanada.ca/easybuild/software/2020/Core/intel/2020.1.217/compilers_and_libraries_2020.1.217/linux/bin/intel64:/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/gcccore/9.3.0/bin:/cvmfs/soft.computecanada.ca/easybuild/bin:/cvmfs/soft.computecanada.ca/custom/bin:/cvmfs/soft.computecanada.ca/gentoo/2020/usr/sbin:/cvmfs/soft.computecanada.ca/gentoo/2020/usr/bin:/cvmfs/soft.computecanada.ca/gentoo/2020/sbin:/cvmfs/soft.computecanada.ca/gentoo/2020/bin:/cvmfs/soft.computecanada.ca/custom/bin/computecanada:/globalhome/olf067/HPC/.local/bin:/cm/shared/bin:/opt/software/bin:/opt/software/slurm/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/dell/srvadmin/bin)
We can load the R
command with module load
(be careful of the case of the
letters, r
vs R
):
[nsid@platolgn01 ~]$ module load r
[nsid@platolgn01 ~]$ which R
/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/r/4.3.1/bin/R
So, what just happened?
To understand the output, first we need to understand the nature of the $PATH
environment
variable. $PATH
is a special environment variable that controls where a UNIX system looks for
software. Specifically $PATH
is a list of directories (separated by :
) that the OS searches
through for a command before giving up and telling us it can’t find it. As with all environment
variables we can print it out using echo
.
[nsid@platolgn01 ~]$ echo $PATH
/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/r/4.3.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/java/13.0.2:/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/java/13.0.2/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/flexiblas/3.0.4/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Compiler/intel2020/openmpi/4.0.3/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/libfabric/1.10.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/ucx/1.8.0/bin:/cvmfs/restricted.computecanada.ca/easybuild/software/2020/Core/intel/2020.1.217/compilers_and_libraries_2020.1.217/linux/bin/intel64:/cvmfs/soft.computecanada.ca/easybuild/software/2020/Core/gcccore/9.3.0/bin:/cvmfs/soft.computecanada.ca/easybuild/bin:/cvmfs/soft.computecanada.ca/custom/bin:/cvmfs/soft.computecanada.ca/gentoo/2020/usr/sbin:/cvmfs/soft.computecanada.ca/gentoo/2020/usr/bin:/cvmfs/soft.computecanada.ca/gentoo/2020/sbin:/cvmfs/soft.computecanada.ca/gentoo/2020/bin:/cvmfs/soft.computecanada.ca/custom/bin/computecanada:/globalhome/olf067/HPC/.local/bin:/cm/shared/bin:/opt/software/bin:/opt/software/slurm/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/dell/srvadmin/bin
You’ll notice a similarity to the output of the which
command. In this case, there’s only one
difference: the different directory at the beginning. When we ran the module load
command,
it added a directory to the beginning of our $PATH
. Let’s examine what’s there:
[nsid@platolgn01 ~]$ ls /cvmfs/soft.computecanada.ca/easybuild/software/2020/avx2/Core/r/4.3.1/bin
R* Rscript*
Taking this to its conclusion, module load
will add software to your $PATH
. It “loads”
software. The module load
command will also load required software dependencies.
To demonstrate, let’s use module list
. module list
shows all loaded software modules.
[nsid@platolgn01 ~]$ module list
Currently Loaded Modules:
1) CCconfig 5) intel/2020.1.217 (t) 9) StdEnv/2020 (S)
2) gentoo/2020 (S) 6) ucx/1.8.0 10) flexiblascore/.3.0.4 (H)
3) gcccore/.9.3.0 (H) 7) libfabric/1.10.1 11) java/13.0.2 (t)
4) imkl/2020.1.217 (math) 8) openmpi/4.0.3 (m) 12) r/4.3.1 (t)
[Some output removed for clarity]
In this case, loading the r
module also loaded java/13.0.2
.
[nsid@platolgn01 ~]$ module unload r
[nsid@platolgn01 ~]$ module list
Currently Loaded Modules:
1) CCconfig 4) imkl/2020.1.217 (math) 7) libfabric/1.10.1
2) gentoo/2020 (S) 5) intel/2020.1.217 (t) 8) openmpi/4.0.3 (m)
3) gcccore/.9.3.0 (H) 6) ucx/1.8.0 9) StdEnv/2020 (S)
[Some output removed for clarity]
So using module unload
“un-loads” a module along with its dependencies. If we wanted to unload
everything at once, we could run module purge
.
[nsid@platolgn01 ~]$ module load r
[nsid@platolgn01 ~]$ module load python
[nsid@platolgn01 ~]$ module purge
The following modules were not unloaded:
(Use "module --force purge" to unload all):
1) CCconfig 4) imkl/2020.1.217 7) libfabric/1.10.1
2) gentoo/2020 5) intel/2020.1.217 8) openmpi/4.0.3
3) gcccore/.9.3.0 6) ucx/1.8.0 9) StdEnv/2020
Note that module purge
does not, by default, unload the core modules that were
already loaded when we logged in. Therefore, module purge
is useful to “reset”
your environment.
Software versioning
So far, we’ve learned how to load and unload software packages. This is very useful. However, we have not yet addressed the issue of software versioning. At some point or other, you will run into issues where only one particular version of some software will be suitable. Perhaps a key bugfix only happened in a certain version, or version X broke compatibility with a file format you use. In either of these example cases, it helps to be very specific about what software is loaded.
Let’s examine the output of module avail gcc
.
[nsid@platolgn01 ~]$ module avail gcc
[Some output removed for clarity]
-------------------------------------- Core Modules --------------------------------------
gcc/8.4.0 (t) gcc/10.2.0 (t) gcc/11.3.0 (t)
gcc/9.3.0 (t,D) gcc/10.3.0 (t)
[Some output removed for clarity]
Let’s take a closer look at the gcc
module. GCC is an extremely widely used C/C++/Fortran
compiler. Tons of software is dependent on the GCC version, and might not compile or run if the
wrong version is loaded. In this case, several versions are available.
How do we load each one and which one is the default?
In this case, gcc/9.3.0
has a (D)
next to it. This indicates that it is the default - if we type
module load gcc
, this is the version that will be loaded.
[nsid@platolgn01 ~]$ module load gcc
[nsid@platolgn01 ~]$ gcc --version
Lmod is automatically replacing "intel/2020.1.217" with "gcc/9.3.0".
Due to MODULEPATH changes, the following have been reloaded:
1) openmpi/4.0.3
gcc (GCC) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Note that three things happened: the default version of GCC was loaded (version 9.3.0), the Intel
compilers (which conflict with GCC) were unloaded, and software that is dependent on compiler
(OpenMPI) was reloaded. The module
system turned what might be a super-complex operation into a
single command.
So how do we load a non-default version of a software package? In this case, the
only change we need to make is be more specific about the module we are loading
by leaving in the version number after the /
.
[nsid@platolgn01 ~]$ module load gcc/10.2.0
[nsid@platolgn01 ~]$ gcc --version
Inactive Modules:
1) openmpi
The following have been reloaded with a version change:
1) gcc/9.3.0 => gcc/10.2.0 2) gcccore/.9.3.0 => gcccore/.10.2.0
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
We now have successfully switched from GCC 9.3.0 to GCC 10.2.0. Because OpenMPI is not available for that specific version of GCC, its module was inactivated.
Using software modules in scripts
Create a job that is able to run
R --version
. Remember, no software is loaded by default! Running a job is just like logging on to the system (you should not assume a module loaded on the login node is loaded on a compute node).Solution
[nsid@platolgn01 ~]$ nano job-with-module.sh [nsid@platolgn01 ~]$ cat job-with-module.sh
#!/bin/bash module load r/4.3.1 R --version
[nsid@platolgn01 ~]$ sbatch job-with-module.sh
Key Points
Load software with
module load softwareName
Unload software with
module purge
The module system handles software versioning and package conflicts for you automatically.