Explain how the shell environment changes when the module mechanism
loads or unloads packages.
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 well known examples are Python 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 run on a machine
that has older C libraries installed will result in an opaque
'GLIBCXX_3.4.20' not found error.
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 allows
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 require 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:
module avail after module load 2025 is a
long list. The line above is the Python build this lesson loads. Use
module spider Python when the name is missing from
module avail.
module load 2025 loads EESSI 2025.06, so
module avail shows that stack. The Python line is the same
build the Snellius tab names. module spider searches names
that module avail hides until another module is loaded.
BASH
[yourUsername@login1 ~]$ module avail |less
OUTPUT
~~~ /cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/modules/all ~~~
Bazel/3.6.0-GCCcore-x.y.z NSS/3.51-GCCcore-x.y.z
Bison/3.5.3-GCCcore-x.y.z Ninja/1.10.0-GCCcore-x.y.z
Boost/1.72.0-gompi-2020a OSU-Micro-Benchmarks/5.6.3-gompi-2020a
CGAL/4.14.3-gompi-2020a-Python-3.x.y OpenBLAS/0.3.9-GCC-x.y.z
CMake/3.16.4-GCCcore-x.y.z OpenFOAM/v2006-foss-2020a
[removed most of the output here for clarity]
Where:
L: Module is loaded
D: Default Module
Aliases exist: foo/1.2.3 (1.2) means that
"module load foo/1.2" will load foo/1.2.3
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".
Note that piping the output through less allows us to
search within the output using the / key.
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.
BASH
[YOUR_LOGIN@int4 ~]$ module list
BASH
[YOUR_LOGIN@LOGIN ~]$ module list
BASH
[yourUsername@login1 ~]$ module list
OUTPUT
No modules loaded
Loading and Unloading Software
To load a software module, use module load.
In this example we will use “Python 3”. Initially, it is not loaded.
We can test this by using the which command.
which searches for executables using directories listed in
$PATH, similar to how Bash locates commands.
BASH
[YOUR_LOGIN@int4 ~]$ which python3
BASH
[YOUR_LOGIN@LOGIN ~]$ which python3
BASH
[yourUsername@login1 ~]$ which python3
If the python3 command is available, which
shows the path to the executable:
OUTPUT
/usr/bin/python3
The shell finds executables by searching through the directories
listed in the $PATH environment variable.
If we accidentally make a typo for example:
BASH
[YOUR_LOGIN@int4 ~]$ which pyython3
we instead see something like:
OUTPUT
/usr/bin/which: no pyython3 in (/home/YOUR_LOGIN/.local/bin:/home/YOUR_LOGIN/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
This wall of text is actually a list of directories separated by the
: character. The output tells us that the shell searched
the following directories for pyython3, but could not find
it:
The Python installation located in /usr/bin is the
system-provided version. On HPC systems, we often need a different
Python build that is compiled with specific compiler toolchains,
libraries, or scientific software stacks. Environment Modules allow us
to dynamically switch to these alternative software environments.
If the python3 command is available, which
shows the path to the executable:
OUTPUT
/usr/bin/python3
The shell finds executables by searching through the directories
listed in the $PATH environment variable.
If we accidentally make a typo for example:
BASH
[YOUR_LOGIN@LOGIN ~]$ which pyython3
we instead see something like:
OUTPUT
/usr/bin/which: no pyython3 in (/home/YOUR_LOGIN/.local/bin:/home/YOUR_LOGIN/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
This wall of text is actually a list of directories separated by the
: character. The output tells us that the shell searched
the following directories for pyython3, but could not find
it:
The Python installation located in /usr/bin is the
system-provided version. On HPC systems, we often need a different
Python build that is compiled with specific compiler toolchains,
libraries, or scientific software stacks. Environment Modules allow us
to dynamically switch to these alternative software environments.
If the python3 command is available, which
shows the path to the executable:
OUTPUT
/usr/bin/python3
The shell finds executables by searching through the directories
listed in the $PATH environment variable.
If we accidentally make a typo for example:
BASH
[yourUsername@login1 ~]$ which pyython3
we instead see something like:
OUTPUT
/usr/bin/which: no pyython3 in (/home/yourUsername/.local/bin:/home/yourUsername/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin)
This wall of text is actually a list of directories separated by the
: character. The output tells us that the shell searched
the following directories for pyython3, but could not find
it:
The Python installation located in /usr/bin is the
system-provided version. On HPC systems, we often need a different
Python build that is compiled with specific compiler toolchains,
libraries, or scientific software stacks. Environment Modules allow us
to dynamically switch to these alternative software environments.
We can load a different Python environment using
module load:
module load 2025 selects the 2025 site stack.
which python3 then prints a path in that stack. Read the
path on the login node. This sample does not invent it.
module load 2025 loads EESSI 2025.06. The same
python3 --version line is Python 3.13.5.
which python3 prints a path under
/cvmfs/software.eessi.io. The exact directory depends on
the CPU target, so this sample does not invent it.
BASH
[yourUsername@login1 ~]$ module load Python[yourUsername@login1 ~]$ which python3
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 shell looks for
executables. Specifically, $PATH is a list of directories
(separated by :) that the shell searches through for a
command before reporting that the command could not be found. As with
all environment variables, we can print it out using
echo.
You’ll notice a similarity to the output of the which
command. In this case, there is one important difference: an additional
directory appears at the beginning. When we ran the
module load command, it added a directory to the front of
our $PATH – or “prepended to PATH”. Because this directory
appears before /usr/bin in $PATH, the shell
now finds the module-provided python3 executable before the
system version. Let’s examine what’s located there:
module load 2025 loads EESSI 2025.06.
dirname prints a directory under
/cvmfs/software.eessi.io for the CPU target on that node.
The directory contains python3 and pip3.
BASH
[yourUsername@login1 ~]$ ls /cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/Python/3.x.y-GCCcore-x.y.z/bin
Note that the exact output may vary from cluster to cluster.
Taking this to its conclusion, module load adds software
locations to your $PATH. It effectively “loads” software
into the current shell environment. A special note on this: depending on
the module system configuration at your site,
module load may also automatically load additional software
dependencies required by the application.
To demonstrate, let’s use module list.
module list shows all loaded software modules.
So in this case, loading the GROMACS module (a
bioinformatics software package), also loaded
GMP/6.2.0-GCCcore-x.y.z and
SciPy-bundle/2020.03-foss-2020a-Python-3.x.y as well. Let’s
try unloading the GROMACS package.
BASH
[YOUR_LOGIN@int4 ~]$ module unload GROMACS[YOUR_LOGIN@int4 ~]$ module list
So using module unload “un-loads” a module, and
depending on how a site is configured it may also unload all of the
dependencies (in our case it does not). If we wanted to unload
everything at once, we could run module purge (unloads
everything).
BASH
[YOUR_LOGIN@int4 ~]$ module purge[YOUR_LOGIN@int4 ~]$ module list
OUTPUT
No modules loaded
Note that module purge is informative. It will also let
us know if a default set of “sticky” packages cannot be unloaded (and
how to actually unload these if we truly so desired).
To demonstrate, let’s use module list.
module list shows all loaded software modules.
So in this case, loading the GROMACS module (a
bioinformatics software package), also loaded
GMP/6.2.0-GCCcore-x.y.z and
SciPy-bundle/2020.03-foss-2020a-Python-3.x.y as well. Let’s
try unloading the GROMACS package.
BASH
[YOUR_LOGIN@LOGIN ~]$ module unload GROMACS[YOUR_LOGIN@LOGIN ~]$ module list
So using module unload “un-loads” a module, and
depending on how a site is configured it may also unload all of the
dependencies (in our case it does not). If we wanted to unload
everything at once, we could run module purge (unloads
everything).
BASH
[YOUR_LOGIN@LOGIN ~]$ module purge[YOUR_LOGIN@LOGIN ~]$ module list
OUTPUT
No modules loaded
Note that module purge is informative. It will also let
us know if a default set of “sticky” packages cannot be unloaded (and
how to actually unload these if we truly so desired).
To demonstrate, let’s use module list.
module list shows all loaded software modules.
So in this case, loading the GROMACS module (a
bioinformatics software package), also loaded
GMP/6.2.0-GCCcore-x.y.z and
SciPy-bundle/2020.03-foss-2020a-Python-3.x.y as well. Let’s
try unloading the GROMACS package.
BASH
[yourUsername@login1 ~]$ module unload GROMACS[yourUsername@login1 ~]$ module list
So using module unload “un-loads” a module, and
depending on how a site is configured it may also unload all of the
dependencies (in our case it does not). If we wanted to unload
everything at once, we could run module purge (unloads
everything).
BASH
[yourUsername@login1 ~]$ module purge[yourUsername@login1 ~]$ module list
OUTPUT
No modules loaded
Note that module purge is informative. It will also let
us know if a default set of “sticky” packages cannot be unloaded (and
how to actually unload these if we truly so desired).
Note that this module loading process happens primarily through the
manipulation of environment variables like $PATH. There is
usually little or no data transfer involved.
The module system modifies other environment variables as well,
including variables that influence where the shell and runtime linker
look for software libraries. Examples include variables such as:
On some systems, modules may also configure environment variables
that tell commercial software packages where to locate license servers.
The module command restores these shell environment
variables to their previous state when a module is unloaded. This allows
users to switch between different software environments cleanly and
reproducibly.
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,
using the pager since there may be reams of output:
module avail after module load 2025 is a
long list. The line above is the Python build this lesson loads. Use
module spider Python when the name is missing from
module avail.
module load 2025 loads EESSI 2025.06, so
module avail shows that stack. The Python line is the same
build the Snellius tab names. module spider searches names
that module avail hides until another module is loaded.
BASH
[yourUsername@login1 ~]$ module avail |less
OUTPUT
~~~ /cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/modules/all ~~~
Bazel/3.6.0-GCCcore-x.y.z NSS/3.51-GCCcore-x.y.z
Bison/3.5.3-GCCcore-x.y.z Ninja/1.10.0-GCCcore-x.y.z
Boost/1.72.0-gompi-2020a OSU-Micro-Benchmarks/5.6.3-gompi-2020a
CGAL/4.14.3-gompi-2020a-Python-3.x.y OpenBLAS/0.3.9-GCC-x.y.z
CMake/3.16.4-GCCcore-x.y.z OpenFOAM/v2006-foss-2020a
[removed most of the output here for clarity]
Where:
L: Module is loaded
D: Default Module
Aliases exist: foo/1.2.3 (1.2) means that
"module load foo/1.2" will load foo/1.2.3
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".
If the software your Slurm script runs requires on a specific version
of a dependency, make sure you use the full name of the module, rather
than the default loaded when you give only its name (up to the
first slash).
Challenge
Using Software Modules in Scripts
Create a job that is able to run python3 --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).