Accessing software

Overview

Teaching: 30 min
Exercises: 15 min
Questions
  • 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 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.

A dependency exists when 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) gcc/12.3    (t)   7) libfabric/1.18.0  10) openmpi/4.1.5   (m)     13) StdEnv/2023 (S)
  2) gentoo/2023   (S)   5) hwloc/2.9.1       8) pmix/4.2.4        11) flexiblas/3.3.1         14) mii/1.1.2
  3) gcccore/.12.3 (H)   6) ucx/1.14.1        9) ucc/1.2.0         12) imkl/2023.2.0   (math)

[Some output removed for brevity]

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/2023/x86-64-v3/Core/flexiblascore/3.3.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcc12/openmpi/4.1.5/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/ucc/1.2.0/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/pmix/4.2.4/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/libfabric/1.18.0/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/ucx/1.14.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/hwloc/2.9.1/sbin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/hwloc/2.9.1/bin:/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/gcc-bin/12:/cvmfs/soft.computecanada.ca/easybuild/bin:/cvmfs/soft.computecanada.ca/custom/bin:/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/bin:/cvmfs/soft.computecanada.ca/custom/bin/computecanada:/opt/software/bin:/cm/shared/apps/slurm/current/sbin:/cm/shared/apps/slurm/current/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/globalhome/cbe453/HPC/.local/bin:/globalhome/cbe453/HPC/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/2023/x86-64-v3/Compiler/gcccore/r/4.4.0/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/2023/x86-64-v3/Compiler/gcccore/r/4.4.0/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Core/java/17.0.6:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Core/java/17.0.6/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Core/flexiblascore/3.3.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Core/flexiblascore/3.3.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcc12/openmpi/4.1.5/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/ucc/1.2.0/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/pmix/4.2.4/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/libfabric/1.18.0/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/ucx/1.14.1/bin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/hwloc/2.9.1/sbin:/cvmfs/soft.computecanada.ca/easybuild/software/2023/x86-64-v3/Compiler/gcccore/hwloc/2.9.1/bin:/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/gcc-bin/12:/cvmfs/soft.computecanada.ca/easybuild/bin:/cvmfs/soft.computecanada.ca/custom/bin:/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/bin:/cvmfs/soft.computecanada.ca/custom/bin/computecanada:/opt/software/bin:/cm/shared/apps/slurm/current/sbin:/cm/shared/apps/slurm/current/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/globalhome/cbe453/HPC/.local/bin:/globalhome/cbe453/HPC/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/2023/x86-64-v3/Compiler/gcccore/r/4.4.0/bin/R
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) hwloc/2.9.1        9) ucc/1.2.0               13) StdEnv/2023            (S)
  2) gentoo/2023   (S)   6) ucx/1.14.1        10) openmpi/4.1.5   (m)     14) flexiblascore/.3.3.1   (H)
  3) gcccore/.12.3 (H)   7) libfabric/1.18.0  11) flexiblas/3.3.1         15) java/17 -> java/17.0.6 (t)
  4) gcc/12.3      (t)   8) pmix/4.2.4        12) imkl/2023.2.0   (math)  16) r/4.4.0                (t)

[Some output removed for clarity]

In this case, loading the r module also loaded java/17.0.6.

[nsid@platolgn01 ~]$ module unload r
[nsid@platolgn01 ~]$ module list
Currently Loaded Modules:
  1) CCconfig            5) hwloc/2.9.1        9) ucc/1.2.0               13) StdEnv/2023            (S)
  2) gentoo/2023   (S)   6) ucx/1.14.1        10) openmpi/4.1.5   (m)     14) java/17 -> java/17.0.6 (t)
  3) gcccore/.12.3 (H)   7) libfabric/1.18.0  11) flexiblas/3.3.1
  4) gcc/12.3      (t)   8) pmix/4.2.4        12) imkl/2023.2.0   (math)

[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) gcc/12.3      7) libfabric/1.18.0   10) openmpi/4.1.5     13) StdEnv/2023
  2) gentoo/2023     5) hwloc/2.9.1   8) pmix/4.2.4         11) flexiblas/3.3.1
  3) gcccore/.12.3   6) ucx/1.14.1    9) ucc/1.2.0          12) imkl/2023.2.0

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 more specific about what version of a software is loaded.

In the previous example, running module load r loaded version 4.4.0 (r/4.4.0). Since we did not specify a version, a default version was loaded. The default versions may change periodically as software and standard environments change, so we should learn to find and load specific versions of software. Let’s examine the output of module spider gromacs. GROMACS is a popular open-source suite of tools for high-performance molecular dynamics and output analysis

[nsid@platolgn01 ~]$ module spider gromacs
----------------------------------------------------------------------------------------------------------
  gromacs:
----------------------------------------------------------------------------------------------------------
    Description:
      GROMACS is a versatile package to perform molecular dynamics, i.e. simulate the Newtonian equations
      of motion for systems with hundreds to millions of particles. This is a CPU only build, containing
      both MPI and threadMPI builds.

     Versions:
        gromacs/2016.6
        gromacs/2020.4
        gromacs/2020.6
        gromacs/2021.2
        gromacs/2021.4
        gromacs/2021.6
        gromacs/2022.2
        gromacs/2022.3
        gromacs/2023
        gromacs/2023.2
        gromacs/2023.3
        gromacs/2023.5
        gromacs/2024.1
        gromacs/2024.4
     Other possible modules matches:
        gromacs-colvars  gromacs-cp2k  gromacs-ls  gromacs-plumed  gromacs-ramd  gromacs-swaxs

----------------------------------------------------------------------------------------------------------
  To find other possible module matches execute:

      $ module -r spider '.*gromacs.*'

----------------------------------------------------------------------------------------------------------
  For detailed information about a specific "gromacs" package (including how to load the modules) use the module's full name.
  Note that names that have a trailing (E) are extensions provided by other modules.
  For example:

     $ module spider gromacs/2024.4
----------------------------------------------------------------------------------------------------------

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 gromacs/2023.3
[nsid@platolgn01 ~]$ gmx

The following have been reloaded with a version change:
  1) gromacs/2024.4 => gromacs/2023.3

We now have successfully switched from GROMACS 2024.4 to GROMACS 2023.3. We are notified of the version change, and it appears that no dependencies required version changes.

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.