Accessing software via Modules

Last updated on 2026-10-20 | Edit this page

Overview

Questions

  • How do we load and unload software packages?

Objectives

  • Load and use a software package.
  • 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:

BASH

user@wayland-2022:~$ module avail | less

OUTPUT

--------------------------------------- /usr/shared_apps/Nmodules/apps ---------------------------------------
abaqus/2019           cplex/12.5.1              gromacs/2020          octopus/test         vim/8.1
adf/test              cplex/12.9                gromacs/cpu-test      OpenBUGS/3.2.3       vtune/21.0u4
amber/18              cplex/22.11               gulp/6.3.4            OpenFOAM/1912        wine/2.0.3
amber/test            crystal/23                gurobi/9.0.0          OpenFOAM/2106        wrf/test
anaconda2/2.5.0       CST/2022u5                highs/1.5.3           openmolcas/test      xed/5.2.2
anaconda2/4.2.0       CST/2024u5                hisat2/test           paml/4.8
anaconda3/4.1.1       dalton/2018.2             idl/8.9               paraview/5.5.2
anaconda3/4.3.1       dalton/2018.2-large       ImageMagick/7.0.9     patchdock/test
anaconda3/2018.12     dalton/2020.0-large       intel-python/2.7      perl/5.12.3
anaconda3/2018.12-tf  delft3d/6.04.02           intel-python/3.6      pflotran/201708
anaconda3/2019.07     delft3d/test              JAGS/4.3.0            poreblazer/4.0
anaconda3/2020.11     delft3d/test-fm           JAGS/4.3.2            pyqsub/test
anaconda3/2022.05     dl-poly-classic/1.9       julia/1.0.1           R/3.5.1
anaconda3/2023.09     dl-poly/4.06              julia/1.6.3           R/3.5.1-gcc

[removed most of the output here for clarity]

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

user@wayland-2022:~$ 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

user@wayland-2022:~$ 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

user@wayland-2022:~$ which pyython3

we instead see something like:

OUTPUT

/usr/bin/which: no pyython3 in (/user/.local/bin:/user/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:

OUTPUT

/user/.local/bin
/user/bin
/usr/local/bin
/usr/bin
/usr/local/sbin
/usr/sbin

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:

BASH

user@wayland-2022:~$ module load miniforge
user@wayland-2022:~$ which python3

OUTPUT

/cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/Python/3.x.y-GCCcore-x.y.z/bin/python3

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 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.

BASH

user@wayland-2022:~$ echo $PATH

OUTPUT

/cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/Python/3.x.y-GCCcore-x.y.z/bin:/cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/SQLite/3.31.1-GCCcore-x.y.z/bin:/cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/Tcl/8.6.10-GCCcore-x.y.z/bin:/cvmfs/pilot.eessi-hpc.org/2020.12/software/x86_64/amd/zen2/software/GCCcore/x.y.z/bin:/cvmfs/pilot.eessi-hpc.org/2020.12/compat/linux/x86_64/usr/bin:/opt/software/slurm/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/puppetlabs/bin:/home/user01/.local/bin:/home/user01/bin

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:

BASH

user@wayland-2022:~$ ls /usr/shared_apps/packages/miniforge3-20251003/bin

OUTPUT

2to3          bzmore       icu-config     kswitch           pydoc              tput
2to3-3.12     captoinfo    icuexportdata  ktutil            pydoc3             tqdm
activate      clear        icuinfo        kvno              pydoc3.12          tset
adig          compile_et   idle3          lz4               python             unlz4
ahost         conda        idle3.12       lz4c              python3            unzstd
archspec      conda2solv   infocmp        lz4cat            python3.1          uuclient
bsdcat        conda-env    infotocap      makeconv          python3.12         wheel
bsdcpio       cph          installcheck   mamba             python3.12-config  wish
bsdtar        c_rehash     jsondiff       mamba-package     python3-config     wish8.6
bsdunzip      curl-config  jsonpatch      mergesolv         repo2solv          x86_64-conda-linux-gnu-ld
bunzip2       deactivate   jsonpointer    ncurses6-config   reset              xml2-config
bzcat         derb         k5srvutil      ncursesw6-config  sclient            xmlcatalog
bzcmp         distro       kadmin         nghttp            sim_client         xmllint
bzdiff        dumpsolv     kdestroy       nghttpd           sqlite3_analyzer   zstd
bzegrep       genbrk       keyctl         nghttpx           tabs               zstdcat
bzfgrep       gencfu       kinit          normalizer        tclsh              zstdgrep
bzgrep        gencnval     klist          openssl           tclsh8.6           zstdless
bzip2         gendict      kpasswd        pip               testsolv           zstdmt
bzip2recover  genrb        krb5-config    pip3              tic
bzless        gss-client   ksu            pkgdata           toe

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.

BASH

user@wayland-2022:~$ module list

OUTPUT

Currently Loaded Modulefiles:
 1) vim/8.1   2) intel/20.0u3   3) git/2.49.0   4) miniforge/20251003

Key:
default-version

BASH

user@wayland-2022:~$ module load espresso/7.2-cuda
user@wayland-2022:~$ module list

OUTPUT

Currently Loaded Modulefiles:
 1) vim/8.1        3) git/2.49.0           5) nv-hpc-sdk/21.3
 2) intel/20.0u3   4) miniforge/20251003   6) espresso/7.2-cuda

Key:
auto-loaded  default-version

So in this case, loading the espresso module (quantum ESPRESSO, a density functional theory code), also loaded nv-hpc-sdk/21.3. Let’s try unloading the espresso package.

BASH

user@wayland-2022:~$ module unload espresso/7.2-cuda
user@wayland-2022:~$ module list

OUTPUT

Currently Loaded Modulefiles:
 1) vim/8.1   2) intel/20.0u3   3) git/2.49.0   4) miniforge/20251003

Key:
default-version

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

user@wayland-2022:~$ module purge
user@wayland-2022:~$ 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:

OUTPUT

LD_LIBRARY_PATH
LIBRARY_PATH
CPATH
MANPATH
PKG_CONFIG_PATH

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:

BASH

user@wayland-2022:~$ module avail | less

OUTPUT

--------------------------------------- /usr/shared_apps/Nmodules/apps ---------------------------------------
abaqus/2019           cplex/12.5.1              gromacs/2020          octopus/test         vim/8.1
adf/test              cplex/12.9                gromacs/cpu-test      OpenBUGS/3.2.3       vtune/21.0u4
amber/18              cplex/22.11               gulp/6.3.4            OpenFOAM/1912        wine/2.0.3
amber/test            crystal/23                gurobi/9.0.0          OpenFOAM/2106        wrf/test
anaconda2/2.5.0       CST/2022u5                highs/1.5.3           openmolcas/test      xed/5.2.2
anaconda2/4.2.0       CST/2024u5                hisat2/test           paml/4.8
anaconda3/4.1.1       dalton/2018.2             idl/8.9               paraview/5.5.2
anaconda3/4.3.1       dalton/2018.2-large       ImageMagick/7.0.9     patchdock/test
anaconda3/2018.12     dalton/2020.0-large       intel-python/2.7      perl/5.12.3
anaconda3/2018.12-tf  delft3d/6.04.02           intel-python/3.6      pflotran/201708
anaconda3/2019.07     delft3d/test              JAGS/4.3.0            poreblazer/4.0
anaconda3/2020.11     delft3d/test-fm           JAGS/4.3.2            pyqsub/test
anaconda3/2022.05     dl-poly-classic/1.9       julia/1.0.1           R/3.5.1
anaconda3/2023.09     dl-poly/4.06              julia/1.6.3           R/3.5.1-gcc

[removed most of the output here for clarity]

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).

BASH

user@wayland-2022:~$ nano python-module.sh
user@wayland-2022:~$ cat python-module.sh

OUTPUT

#!/bin/bash
#SBATCH

#SBATCH --time 00:00:30

module load miniforge

python3 --version

BASH

user@wayland-2022:~$ sbatch --partition=serial python-module.sh
Key Points
  • Load software with module load softwareName.
  • Unload software with module unload
  • The module system handles software versioning and package conflicts for you automatically.