This lesson is in the early stages of development (Alpha version)

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 often the case that no software is loaded by default. If we want to use a software package, we will need to “load” it ourselves.

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.

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 Fourer 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 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@login12 ~]$  module list
No Modulefiles Currently Loaded.

Listing available modules

To see available software modules, use module avail

[yourUsername@login12 ~]$  module avail
---------------------- /shared/ucl/apps/modulefiles/core -----------------------
gerun             ops-tools/1.1.0   screen/4.2.1      userscripts/1.3.0
lm-utils/1.0      ops-tools/2.0.0   userscripts/1.0.0 userscripts/1.4.0
mrxvt/0.5.4       rcps-core/1.0.0   userscripts/1.1.0
ops-tools/1.0.0   rlwrap/0.43       userscripts/1.2.0

------------------ /shared/ucl/apps/modulefiles/applications -------------------
abaqus/2017
adf/2014.10
afni/20151030
afni/20181011
amber/14/mpi/intel-2015-update2
amber/14/openmp/intel-2015-update2
amber/14/serial/intel-2015-update2
amber/16/mpi/gnu-4.9.2

[output truncated]

Loading and unloading software

To load a software module, use module load. In this example we will use Python 3.

Initially, Python 3 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@login12 ~]$  which python3
/usr/bin/which: no python3 in (/shared/ucl/apps/python/3.6.3/gnu-4.9.2/bin:/shared/ucl/apps/intel-mpi/ucl-wrapper/bin:/shared/ucl/apps/intel/2018.Update3/impi/2018.3.222/intel64/bin:/shared/ucl/apps/intel/2018.Update3/debugger_2018/gdb/intel64_mic/bin:/shared/ucl/apps/intel/2018.Update3/compilers_and_libraries_2018.3.222/linux/mpi/intel64/bin:/shared/ucl/apps/intel/2018.Update3/compilers_and_libraries_2018.3.222/linux/bin/intel64:/shared/ucl/apps/cluster-bin:/shared/ucl/apps/cluster-scripts:/shared/ucl/apps/mrxvt/0.5.4/bin:/shared/ucl/apps/tmux/2.2/gnu-4.9.2/bin:/shared/ucl/apps/emacs/24.5/gnu-4.9.2/bin:/shared/ucl/apps/giflib/5.1.1/gnu-4.9.2/bin:/shared/ucl/apps/dos2unix/7.3/gnu-4.9.2/bin:/shared/ucl/apps/nano/2.4.2/gnu-4.9.2/bin:/shared/ucl/apps/apr-util/1.5.4/bin:/shared/ucl/apps/apr/1.5.2/bin:/shared/ucl/apps/git/2.19.1/gnu-4.9.2/bin:/shared/ucl/apps/flex/2.5.39/gnu-4.9.2/bin:/shared/ucl/apps/cmake/3.13.3/gnu-4.9.2/bin:/shared/ucl/apps/gcc/4.9.2/bin:/opt/sge/bin:/opt/sge/bin/lx-amd64:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/bin)

We can load the python3 command with module load:

[yourUsername@login12 ~]$  module load python
[yourUsername@login12 ~]$  which python3
/shared/ucl/apps/python/3.6.3/gnu-4.9.2/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 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@login12 ~]$  echo $PATH
/shared/ucl/apps/python/3.6.3/gnu-4.9.2/bin:/shared/ucl/apps/intel-mpi/ucl-wrapper/bin:/shared/ucl/apps/intel/2018.Update3/impi/2018.3.222/intel64/bin:/shared/ucl/apps/intel/2018.Update3/debugger_2018/gdb/intel64_mic/bin:/shared/ucl/apps/intel/2018.Update3/compilers_and_libraries_2018.3.222/linux/mpi/intel64/bin:/shared/ucl/apps/intel/2018.Update3/compilers_and_libraries_2018.3.222/linux/bin/intel64:/shared/ucl/apps/cluster-bin:/shared/ucl/apps/cluster-scripts:/shared/ucl/apps/mrxvt/0.5.4/bin:/shared/ucl/apps/tmux/2.2/gnu-4.9.2/bin:/shared/ucl/apps/emacs/24.5/gnu-4.9.2/bin:/shared/ucl/apps/giflib/5.1.1/gnu-4.9.2/bin:/shared/ucl/apps/dos2unix/7.3/gnu-4.9.2/bin:/shared/ucl/apps/nano/2.4.2/gnu-4.9.2/bin:/shared/ucl/apps/apr-util/1.5.4/bin:/shared/ucl/apps/apr/1.5.2/bin:/shared/ucl/apps/git/2.19.1/gnu-4.9.2/bin:/shared/ucl/apps/flex/2.5.39/gnu-4.9.2/bin:/shared/ucl/apps/cmake/3.13.3/gnu-4.9.2/bin:/shared/ucl/apps/gcc/4.9.2/bin:/opt/sge/bin:/opt/sge/bin/lx-amd64:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/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:

[yourUsername@login12 ~]$  ls /shared/ucl/apps/python/3.6.3/gnu-4.9.2/bin
[output truncated]

conda-convert                       gio-querymodules        jupyter-run               python                tiff2rgba
conda-develop                       glacier                 jupyter-serverextension   python3               tiffcmp
conda-env                           glib-compile-resources  jupyter-troubleshoot      python3.6             tiffcp
conda-index                         glib-compile-schemas    jupyter-trust             python3.6-config      tiffcrop
conda-inspect                       glib-genmarshal         kill_instance             python3.6m            tiffdither
conda-metapackage                   glib-gettextize         launch_instance           python3.6m-config     tiffdump
conda-render                        glib-mkenums            lconvert                  python3-config        tiffinfo
conda-server                        gobject-query           libpng16-config           pyuic5                tiffmedian
conda-skeleton                      gresource               libpng-config             pyvenv                tiffset
elbadmin                            hb-view                 patchelf                  rst2man.py

[output truncated]

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 load the ansys module and then use the module list command to show which modules we currently have loaded in our environment. (ANSYS is an engineering simulation product.)

[yourUsername@login12 ~]$  module load ansys
ansys/2019.r3(73):ERROR:151: Module 'ansys/2019.r3' depends on one of the module(s) 'giflib/5.1.1'
ansys/2019.r3(73):ERROR:102: Tcl command execution failed: prereq   giflib/5.1.1

This shows that the default ansys module will not run because it first needs giflib/5.1.1 to be loaded. Some HPC systems will automatically load dependencies like this, but at the time of writing (June 2020) UCL’s Myriad does not.

Let’s load the giflib module:

[yourUsername@login12 ~]$  module load giflib
giflib/5.1.1(18):ERROR:151: Module 'giflib/5.1.1' depends on one of the module(s) 'gcc-libs/4.9.2'
giflib/5.1.1(18):ERROR:102: Tcl command execution failed: prereq gcc-libs

Here, we see that the giflib module itself also has a dependency, gcc-libs. So we have to load that first, then load giflib, and then finally load ansys.

[yourUsername@login12 ~]$  module load gcc-libs/4.9.2
[yourUsername@login12 ~]$  module load giflib/5.1.1
[yourUsername@login12 ~]$  module load ansys
~/Scratch/.config is configured
...
...
~/.mw doesn't exist - creating

If you now use the module list command, you should see these three modules included in the list.

To unload a specific module, e.g. ansys, run the command module unload ansys. (On some systems, this will also unload the modules it depends on. Currently this is not the case with Myriad.)

If we wanted to unload everything at once (all modules), we could run module purge (unloads everything).

[yourUsername@login12 ~]$  module purge
[yourUsername@login12 ~]$  module list
No Modulefiles Currently Loaded.

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@login12 ~]$  module avail
---------------------- /shared/ucl/apps/modulefiles/core -----------------------
gerun             ops-tools/1.1.0   screen/4.2.1      userscripts/1.3.0
lm-utils/1.0      ops-tools/2.0.0   userscripts/1.0.0 userscripts/1.4.0
mrxvt/0.5.4       rcps-core/1.0.0   userscripts/1.1.0
ops-tools/1.0.0   rlwrap/0.43       userscripts/1.2.0

------------------ /shared/ucl/apps/modulefiles/applications -------------------
abaqus/2017
adf/2014.10
afni/20151030
afni/20181011
amber/14/mpi/intel-2015-update2
amber/14/openmp/intel-2015-update2
amber/14/serial/intel-2015-update2
amber/16/mpi/gnu-4.9.2

[output truncated]

To be more specific, you can specify the particular software you want. e.g.

[yourUsername@login12 ~]$  module avail stata
------------------------------------- /shared/ucl/apps/modulefiles/applications --------------------------------------
stata/14 stata/15

Let’s take a closer look at the matlab module. Matlab is a widely-used piece of software which uses matrix multiplication. As we shall see, there are different versions available, and we want to make sure the one we use is the correct one for our purposes.

Let’s see which versions we have access to.

[yourUsername@login12 ~]$  module avail matlab
------------------------------------- /shared/ucl/apps/modulefiles/applications --------------------------------------
matlab/full/r2015a/8.5 matlab/full/r2016b/9.1 matlab/full/r2018a/9.4 matlab/full/r2019b/9.7
matlab/full/r2015b/8.6 matlab/full/r2017a/9.2 matlab/full/r2018b/9.5

In this case, there are seven different versions. How do we load each copy, and which copy is the default?

Sometimes, on some systems, a module might have a (default) next to it. This indicates that it is the default (i.e. which would be loaded if we type module load matlab). In this case, we don’t see this, so we will have to load matlab and see what we get.

[yourUsername@login12 ~]$  module load matlab
matlab/full/r2019b/9.7(99):ERROR:151: Module 'matlab/full/r2019b/9.7' depends on one of the module(s) 'gcc-libs/4.9.2'
matlab/full/r2019b/9.7(99):ERROR:102: Tcl command execution failed: prereq gcc-libs

Here, we see that the default version of Matlab on the system is r2019b/9.7, which in this case is the most recent version. However, you should not assume that the default version is necessarily the latest.

As we saw in the earlier example, there are one or more dependencies.

Suppose we decide to load an earlier version of Matlab, e.g. r2017a/9.2.

[yourUsername@login12 ~]$  module purge
[yourUsername@login12 ~]$  module list
No Modulefiles Currently Loaded.
[yourUsername@login12 ~]$  module load matlab/full/r2017a/9.2
matlab/full/r2017a/9.2(96):ERROR:151: Module 'matlab/full/r2017a/9.2' depends on one of the module(s) 'gcc-libs/4.9.2'
matlab/full/r2017a/9.2(96):ERROR:102: Tcl command execution failed: prereq gcc-libs
[yourUsername@login12 ~]$  module load gcc-libs/4.9.2
[yourUsername@login12 ~]$  module load matlab/full/r2017a/9.2
matlab/full/r2017a/9.2(97):ERROR:151: Module 'matlab/full/r2017a/9.2' depends on one of the module(s) 'xorg-utils/X11R7.7'
matlab/full/r2017a/9.2(97):ERROR:102: Tcl command execution failed: prereq xorg-utils/X11R7.7
[yourUsername@login12 ~]$  module load xorg-utils/X11R7.7
[yourUsername@login12 ~]$  module load matlab/full/r2017a/9.2
~/.matlab is a symbolic link pointing to /home/yourUsername/Scratch/.matlab

Matlab setup complete type matlab to start Matlab.
[yourUsername@login12 ~]$  matlab -nodisplay -nosplash -nodesktop
                                               < M A T L A B (R) >
                                     Copyright 1984-2017 The MathWorks, Inc.
                                      R2017a (9.2.0.556344) 64-bit (glnxa64)
                                                  March 27, 2017

 
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
 
>> quit

Note that you cannot load two different versions of the same software at once. Currently, we have loaded matlab/full/r2017a/9.2. Let’s try also loading matlab/full/r2015b/8.6:

[yourUsername@login12 ~]$  module load matlab/full/r2015b/8.6
matlab/full/r2015b/8.6(108):ERROR:150: Module 'matlab/full/r2015b/8.6' conflicts with the currently loaded module(s) 'matlab/full/r2017a/9.2'
matlab/full/r2015b/8.6(108):ERROR:102: Tcl command execution failed: conflict matlab

As we can see, we get an error message about conflicts. If we do indeed wish to load version r2015b/8.6, we can say

[yourUsername@login12 ~]$  module unload matlab/full/r2017a/9.2
[yourUsername@login12 ~]$  module load matlab/full/r2015b/8.6

or, in one step:

[yourUsername@login12 ~]$  module swap matlab matlab/full/r2015b/8.6

Check that this module has been loaded:

[yourUsername@login12 ~]$  module list
Currently Loaded Modulefiles:
  1) gcc-libs/4.9.2                 9) gerun                         17) userscripts/1.4.0
  ...                              ...                               ...
  6) apr-util/1.5.4                14) emacs/24.5                    22) xorg-utils/X11R7.7
  7) subversion/1.8.13             15) tmux/2.2                      23) matlab/full/r2015b/8.6
  8) screen/4.2.1                  16) mrxvt/0.5.4

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

Solution

Installing software of our own

Most HPC clusters have a pretty large set of preinstalled software. Nonetheless, it’s unlikely that all of the software we’ll need will be available. Sooner or later, we’ll need to install some software of our own.

Though software installation differs from package to package, the general process is the same: download the software, read the installation instructions (important!), install dependencies, compile, then start using our software.

As an example we will install the bioinformatics toolkit seqtk. We’ll first need to obtain the source code from GitHub using git.

[yourUsername@login12 ~]$  git clone https://github.com/lh3/seqtk.git
Cloning into 'seqtk'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 353 (delta 7), reused 11 (delta 4), pack-reused 339
Receiving objects: 100% (353/353), 169.79 KiB | 5.48 MiB/s, done.
Resolving deltas: 100% (202/202), done.

Now, using the instructions in the README.md file, all we need to do to complete the install is to cd into the seqtk folder and run the command make.

[yourUsername@login12 ~]$  cd seqtk
[yourUsername@login12 ~]$  less README.md
[yourUsername@login12 ~]$  make
gcc -g -Wall -O2 -Wno-unused-function seqtk.c -o seqtk -lz -lm
seqtk.c: In function ‘stk_comp’:
seqtk.c:400:16: warning: variable ‘lc’ set but not used [-Wunused-but-set-variable]
    int la, lb, lc, na, nb, nc, cnt[11];
                ^

It’s done! Now all we need to do to use the program is invoke it like any other program.

[yourUsername@login12 ~]$  ./seqtk
Usage:   seqtk <command> <arguments>
Version: 1.2-r101-dirty

Command: seq       common transformation of FASTA/Q
         comp      get the nucleotide composition of FASTA/Q
         sample    subsample sequences
         subseq    extract subsequences from FASTA/Q
         fqchk     fastq QC (base/quality summary)
         mergepe   interleave two PE FASTA/Q files
         trimfq    trim FASTQ using the Phred algorithm

         hety      regional heterozygosity
         gc        identify high- or low-GC regions
         mutfa     point mutate FASTA at specified positions
         mergefa   merge two FASTA/Q files
         famask    apply a X-coded FASTA to a source FASTA
         dropse    drop unpaired from interleaved PE FASTA/Q
         rename    rename sequence names
         randbase  choose a random base from hets
         cutN      cut sequence at long N
         listhet   extract the position of each het
         hpc       homopolyer-compressed sequence

We’ve successfully built our first piece of software on the cluster!

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.

  • You can edit your .bashrc file to automatically load a software package.