Accessing software via Modules
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
:
[yourUsername@mgmt ~]$ module avail
---------------------------------------------- /mnt/shared/modules/all ------------------------
Autoconf/2.69-GCCcore-10.2.0 UnZip/6.0-GCCcore-10.2.0
Automake/1.16.2-GCCcore-10.2.0 VCFtools/0.1.16-GCC-10.2.0
Autotools/20200321-GCCcore-10.2.0 X11/20201008-GCCcore-10.2.0
BCFtools/1.12-GCC-10.2.0 XML-LibXML/2.0206-GCCcore-10.2.0
BWA/0.7.17-GCC-10.2.0 XZ/5.2.5-GCCcore-10.2.0
Bio-DB-HTS/3.01-GCC-10.2.0 annovar/20200608-GCCcore-10.2.0-Perl-5.32.0
BioPerl/1.7.8-GCCcore-10.2.0 binutils/2.35-GCCcore-10.2.0
Bison/3.5.3 binutils/2.35 (D)
Bison/3.7.1-GCCcore-10.2.0 bzip2/1.0.8-GCCcore-10.2.0
Bison/3.7.1 (D) cURL/7.72.0-GCCcore-10.2.0
Boost/1.74.0-GCC-10.2.0 expat/2.2.9-GCCcore-10.2.0
CMake/3.18.4-GCCcore-10.2.0 flex/2.6.4-GCCcore-10.2.0
DB/18.1.40-GCCcore-10.2.0 flex/2.6.4 (D)
DBD-mysql/4.050-GCC-10.2.0 fontconfig/2.13.92-GCCcore-10.2.0
DB_File/1.855-GCCcore-10.2.0 foss/2020b
Eigen/3.3.8-GCCcore-10.2.0 freebayes/1.3.5-GCC-10.2.0-Java-11.0.2
FFTW/3.3.8-gompi-2020b freetype/2.10.3-GCCcore-10.2.0
FastQC/0.11.9-Java-11 gettext/0.21-GCCcore-10.2.0
GCC/10.2.0 gettext/0.21 (D)
GCCcore/10.2.0 gompi/2020b
GMP/6.2.0-GCCcore-10.2.0 gperf/3.1-GCCcore-10.2.0
GSL/2.6-GCC-10.2.0 groff/1.22.4-GCCcore-10.2.0
HTSlib/1.11-GCC-10.2.0 help2man/1.47.4
HTSlib/1.12-GCC-10.2.0 (D) help2man/1.47.16-GCCcore-10.2.0 (D)
IGV/2.9.4-Java-11 hwloc/2.2.0-GCCcore-10.2.0
Java/11.0.2 (11) hypothesis/5.41.2-GCCcore-10.2.0
Java/13.0.2 (D:13) intltool/0.51.0-GCCcore-10.2.0
Judy/1.0.5-GCCcore-10.2.0 jemalloc/5.2.1-GCCcore-10.2.0
LZO/2.10-GCCcore-10.2.0 libaio/0.3.112-GCCcore-10.2.0
LibTIFF/4.1.0-GCCcore-10.2.0 libarchive/3.4.3-GCCcore-10.2.0
M4/1.4.18-GCCcore-10.2.0 libevent/2.1.12-GCCcore-10.2.0
M4/1.4.18 (D) libfabric/1.11.0-GCCcore-10.2.0
MariaDB/10.5.8-GCC-10.2.0 libffi/3.3-GCCcore-10.2.0
Meson/0.55.3-GCCcore-10.2.0 libjpeg-turbo/2.0.5-GCCcore-10.2.0
MultiQC/1.9-foss-2020b-Python-3.8.6 libpciaccess/0.16-GCCcore-10.2.0
NASM/2.15.05-GCCcore-10.2.0 libpng/1.6.37-GCCcore-10.2.0
Ninja/1.10.1-GCCcore-10.2.0 libreadline/8.0-GCCcore-10.2.0
OpenBLAS/0.3.12-GCC-10.2.0 libtool/2.4.6-GCCcore-10.2.0
OpenMPI/4.0.5-GCC-10.2.0 libxml2/2.9.10-GCCcore-10.2.0
PMIx/3.1.5-GCCcore-10.2.0 libyaml/0.2.5-GCCcore-10.2.0
Perl/5.32.0-GCCcore-10.2.0 lz4/1.9.2-GCCcore-10.2.0
Pillow/8.0.1-GCCcore-10.2.0 makeinfo/6.7-GCCcore-10.2.0
PyYAML/5.3.1-GCCcore-10.2.0 matplotlib/3.3.3-foss-2020b
Python/2.7.18-GCCcore-10.2.0 ncurses/6.2-GCCcore-10.2.0
Python/3.8.6-GCCcore-10.2.0 (D) ncurses/6.2 (D)
SAMtools/1.12-GCC-10.2.0 networkx/2.5-foss-2020b
SQLite/3.33.0-GCCcore-10.2.0 numactl/2.0.13-GCCcore-10.2.0
ScaLAPACK/2.1.0-gompi-2020b pkg-config/0.29.2-GCCcore-10.2.0
SciPy-bundle/2020.11-foss-2020b pybind11/2.6.0-GCCcore-10.2.0
Tcl/8.6.10-GCCcore-10.2.0 snappy/1.1.8-GCCcore-10.2.0
Tk/8.6.10-GCCcore-10.2.0 util-linux/2.36-GCCcore-10.2.0
Tkinter/3.8.6-GCCcore-10.2.0 xorg-macros/1.19.2-GCCcore-10.2.0
Trimmomatic/0.39-Java-11 zlib/1.2.11-GCCcore-10.2.0
UCX/1.9.0-GCCcore-10.2.0 zlib/1.2.11 (D)
--------------------------------------- /usr/share/lmod/lmod/modulefiles/Core -----------------
lmod settarg
Where:
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
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
[yourUsername@mgmt ~]$ module list
No Modulefiles Currently Loaded.
Loading and Unloading Software
To load a software module, use module load
. In this example we will use
FastQC.
Initially, FastQC 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.
[yourUsername@mgmt ~]$ which fastqc
/usr/bin/which: no fastqc in (/mnt/shared/home/yourUsername/.local/bin:/mnt/shared/home/yourUsername/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
We can load the fastqc
command with module load
:
[yourUsername@mgmt ~]$ module load FastQC
[yourUsername@mgmt ~]$ which fastqc
/mnt/shared/software/FastQC/0.11.9-Java-11/fastqc
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
.
[yourUsername@mgmt ~]$ echo $PATH
/mnt/shared/software/FastQC/0.11.9-Java-11:/mnt/shared/software/Java/11.0.2:/mnt/shared/software/Java/11.0.2/bin:/mnt/shared/home/yourUsername/.local/bin:/mnt/shared/home/yourUsername/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
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:
[yourUsername@mgmt ~]$ ls /mnt/shared/software/FastQC/0.11.9-Java-11
cisd-jhdf5.jar easybuild fastqc_icon.ico Help jbzip2-0.9.jar LICENSE_JHDF5.txt net README.md RELEASE_NOTES.txt sam-1.103.jar uk
Configuration fastqc fastqc.orig INSTALL.txt LICENSE LICENSE.txt org README.txt run_fastqc.bat Templates
Taking this to its conclusion, module load
will add software to your $PATH
.
It “loads” software. A special note on this - depending on which version of the
module
program that is installed at your site, module load
will also load
required software dependencies.
To demonstrate, let’s use module list
. module list
shows all loaded
software modules.
[yourUsername@mgmt ~]$ module list
Currently Loaded Modules:
1) Java/11.0.2 2) FastQC/0.11.9-Java-11
[citc@mgmt ~]$ module load BCFtools/1.12-GCC-10.2.0
[citc@mgmt ~]$ module list
[citc@mgmt ~]$ module unload BCFtools/1.12-GCC-10.2.0
[citc@mgmt ~]$ module list
[yourUsername@mgmt ~]$ module load BCFtools
[yourUsername@mgmt ~]$ module list
Currently Loaded Modules:
1) Java/11.0.2 5) binutils/2.35-GCCcore-10.2.0 9) cURL/7.72.0-GCCcore-10.2.0
2) FastQC/0.11.9-Java-11 6) GCC/10.2.0 10) HTSlib/1.12-GCC-10.2.0
3) GCCcore/10.2.0 7) bzip2/1.0.8-GCCcore-10.2.0 11) GSL/2.6-GCC-10.2.0
4) zlib/1.2.11-GCCcore-10.2.0 8) XZ/5.2.5-GCCcore-10.2.0 12) BCFtools/1.12-GCC-10.2.0
So in this case, loading the BCFtools
module (a bioinformatics software
package), also loaded several other modules including GCC/10.2.0
(a
compiler) and GSL/2.6-GCC-10.2.0
(a scientific computing library)
as well. Let’s try unloading the BCFtools
package.
[yourUsername@mgmt ~]$ module unload BCFtools
[yourUsername@mgmt ~]$ module list
Currently Loaded Modules:
1) Java/11.0.2 5) binutils/2.35-GCCcore-10.2.0 9) cURL/7.72.0-GCCcore-10.2.0
2) FastQC/0.11.9-Java-11 6) GCC/10.2.0 10) HTSlib/1.12-GCC-10.2.0
3) GCCcore/10.2.0 7) bzip2/1.0.8-GCCcore-10.2.0 11) GSL/2.6-GCC-10.2.0
4) zlib/1.2.11-GCCcore-10.2.0 8) XZ/5.2.5-GCCcore-10.2.0
So here module unload
“un-loads” a module *but didn’t unload its dependencies.
Warning re unloading of dependencies
As mentioned previously, there are several versions of the modules system:
- Some are clever and will unload dependencies of a module when you unload that module
- Others will just unload that module but leave dependencies loaded
If you’re unsure of the behaviour on the HPC systems you have access to then:
- You might find the answer in the documentation for that system
- You might be able to run a quick test to check
- You could ask the system administrator
If we wanted to unload everything at once, we could run module purge
(unloads
everything).
[yourUsername@mgmt ~]$ module purge
No modules loaded
Defaut modules
Some HPC systems are configured so some modules are always loaded by default.
module list
will tell you if that is the case and provides instructions on how to unload these modules if you really want to.
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
more closely.
[yourUsername@mgmt ~]$ module avail
---------------------------------------------- /mnt/shared/modules/all ------------------------
Autoconf/2.69-GCCcore-10.2.0 UnZip/6.0-GCCcore-10.2.0
Automake/1.16.2-GCCcore-10.2.0 VCFtools/0.1.16-GCC-10.2.0
Autotools/20200321-GCCcore-10.2.0 X11/20201008-GCCcore-10.2.0
BCFtools/1.12-GCC-10.2.0 XML-LibXML/2.0206-GCCcore-10.2.0
BWA/0.7.17-GCC-10.2.0 XZ/5.2.5-GCCcore-10.2.0
Bio-DB-HTS/3.01-GCC-10.2.0 annovar/20200608-GCCcore-10.2.0-Perl-5.32.0
BioPerl/1.7.8-GCCcore-10.2.0 binutils/2.35-GCCcore-10.2.0
Bison/3.5.3 binutils/2.35 (D)
Bison/3.7.1-GCCcore-10.2.0 bzip2/1.0.8-GCCcore-10.2.0
Bison/3.7.1 (D) cURL/7.72.0-GCCcore-10.2.0
Boost/1.74.0-GCC-10.2.0 expat/2.2.9-GCCcore-10.2.0
CMake/3.18.4-GCCcore-10.2.0 flex/2.6.4-GCCcore-10.2.0
DB/18.1.40-GCCcore-10.2.0 flex/2.6.4 (D)
DBD-mysql/4.050-GCC-10.2.0 fontconfig/2.13.92-GCCcore-10.2.0
DB_File/1.855-GCCcore-10.2.0 foss/2020b
Eigen/3.3.8-GCCcore-10.2.0 freebayes/1.3.5-GCC-10.2.0-Java-11.0.2
FFTW/3.3.8-gompi-2020b freetype/2.10.3-GCCcore-10.2.0
FastQC/0.11.9-Java-11 gettext/0.21-GCCcore-10.2.0
GCC/10.2.0 gettext/0.21 (D)
GCCcore/10.2.0 gompi/2020b
GMP/6.2.0-GCCcore-10.2.0 gperf/3.1-GCCcore-10.2.0
GSL/2.6-GCC-10.2.0 groff/1.22.4-GCCcore-10.2.0
HTSlib/1.11-GCC-10.2.0 help2man/1.47.4
HTSlib/1.12-GCC-10.2.0 (D) help2man/1.47.16-GCCcore-10.2.0 (D)
IGV/2.9.4-Java-11 hwloc/2.2.0-GCCcore-10.2.0
Java/11.0.2 (11) hypothesis/5.41.2-GCCcore-10.2.0
Java/13.0.2 (D:13) intltool/0.51.0-GCCcore-10.2.0
Judy/1.0.5-GCCcore-10.2.0 jemalloc/5.2.1-GCCcore-10.2.0
LZO/2.10-GCCcore-10.2.0 libaio/0.3.112-GCCcore-10.2.0
LibTIFF/4.1.0-GCCcore-10.2.0 libarchive/3.4.3-GCCcore-10.2.0
M4/1.4.18-GCCcore-10.2.0 libevent/2.1.12-GCCcore-10.2.0
M4/1.4.18 (D) libfabric/1.11.0-GCCcore-10.2.0
MariaDB/10.5.8-GCC-10.2.0 libffi/3.3-GCCcore-10.2.0
Meson/0.55.3-GCCcore-10.2.0 libjpeg-turbo/2.0.5-GCCcore-10.2.0
MultiQC/1.9-foss-2020b-Python-3.8.6 libpciaccess/0.16-GCCcore-10.2.0
NASM/2.15.05-GCCcore-10.2.0 libpng/1.6.37-GCCcore-10.2.0
Ninja/1.10.1-GCCcore-10.2.0 libreadline/8.0-GCCcore-10.2.0
OpenBLAS/0.3.12-GCC-10.2.0 libtool/2.4.6-GCCcore-10.2.0
OpenMPI/4.0.5-GCC-10.2.0 libxml2/2.9.10-GCCcore-10.2.0
PMIx/3.1.5-GCCcore-10.2.0 libyaml/0.2.5-GCCcore-10.2.0
Perl/5.32.0-GCCcore-10.2.0 lz4/1.9.2-GCCcore-10.2.0
Pillow/8.0.1-GCCcore-10.2.0 makeinfo/6.7-GCCcore-10.2.0
PyYAML/5.3.1-GCCcore-10.2.0 matplotlib/3.3.3-foss-2020b
Python/2.7.18-GCCcore-10.2.0 ncurses/6.2-GCCcore-10.2.0
Python/3.8.6-GCCcore-10.2.0 (D) ncurses/6.2 (D)
SAMtools/1.12-GCC-10.2.0 networkx/2.5-foss-2020b
SQLite/3.33.0-GCCcore-10.2.0 numactl/2.0.13-GCCcore-10.2.0
ScaLAPACK/2.1.0-gompi-2020b pkg-config/0.29.2-GCCcore-10.2.0
SciPy-bundle/2020.11-foss-2020b pybind11/2.6.0-GCCcore-10.2.0
Tcl/8.6.10-GCCcore-10.2.0 snappy/1.1.8-GCCcore-10.2.0
Tk/8.6.10-GCCcore-10.2.0 util-linux/2.36-GCCcore-10.2.0
Tkinter/3.8.6-GCCcore-10.2.0 xorg-macros/1.19.2-GCCcore-10.2.0
Trimmomatic/0.39-Java-11 zlib/1.2.11-GCCcore-10.2.0
UCX/1.9.0-GCCcore-10.2.0 zlib/1.2.11 (D)
--------------------------------------- /usr/share/lmod/lmod/modulefiles/Core -----------------
lmod settarg
Where:
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
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".
Let’s take a closer look at the Java
module. Java is an widely used
programming language, software for compiling human-readable Java code into
something runnable (Java compiler), and software for running the resulting output from that
compilation process (Java runtime). On HPC systems the second and third of
those are usually provided by one module.
Some software that has components written in Java might depend on specific
versions of the Java compiler and runtime and might not work as desired if the
wrong version of the Java software is loaded. In this case, there are two
different versions: Java/11.0.2
and Java/13.0.2
. How do we load each copy
and which copy is the default?
In this case, Java/13.0.2
has a (D)
next to it. This indicates that it is the
default — if we type module load Java
, this is the copy that will be
loaded.
[yourUsername@mgmt ~]$ module load Java
[yourUsername@mgmt ~]$ java --version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
So how do we load the non-default copy of a software package? In this case, the
only change we need to make is be more specific about the module we are
loading. There are two Java modules: Java/11.0.2
and Java/13.0.2
. To load a
non-default module, the only change we need to make to our module load
command is to leave in the version number after the /
.
[yourUsername@mgmt ~]$ module load Java/11.0.2
[yourUsername@mgmt ~]$ java -version
The following have been reloaded with a version change:
1) Java/13.0.2 => Java/11.0.2
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
We now have successfully switched from Java 13.0.2 to Java 11.0.2.
A warning regarding dependencies
What if there are modules loaded that depend on a specific version of Java at the time you switch to using a different version of Java?
As mentioned previously, there are several versions of the modules system:
- Some will look to see if there is an equivalent module that works with the currently active version of Java and automatically try loading that.
- Other versions aren’t as clever; you may be left with conflicting modules being loaded, which might cause problems.
If you’re unsure of the behaviour on the HPC systems you have access to then:
- You might find the answer in the documentation for that system
- You might be able to run a quick test to check
- You could ask the system administrator
And don’t forget that
module purge
typically removes all loaded modules, so it can be useful to use this before explicitly loading a different set of modules.
Using Software Modules in Scripts
Create a job that is able to run
fastqc --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
[yourUsername@mgmt ~]$ nano fastqc-module.sh [yourUsername@mgmt ~]$ cat fastqc-module.sh
#!/usr/bin/env bash module load FastQC/0.11.9-Java-11 fastqc --version
[yourUsername@mgmt ~]$ sbatch fastqc-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.