Accessing software
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.
Understand how to use modules to load software packages in scheduler job scripts.
On a high-performance computing system, 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 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 Fourer Transform in the West) software library availble 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 packace 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 subcommnands 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 environemnt, 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@cirrus-login0 ~]$ module list
No Modulefiles Currently Loaded.
Listing available modules
To see available software modules, use module avail
[[yourUsername@cirrus-login0 ~]$ module avail
---------------------------------------------- /usr/share/Modules/modulefiles ----------------------------------------------
dot module-git module-info modules mpt/2.16 null perfboost perfcatcher use.own
-------------------------------------------------- /lustre/sw/modulefiles --------------------------------------------------
abinit/8.2.3-intel17-mpt214(default) gdal/2.1.2-gcc6 ipm/2.0.6-impi
allinea/7.0.0(default) gnu-parallel/20170322(default) lammps/31Mar2017-gcc6-mpt214(default)
altair-hwsolvers/13.0.213 gnuplot/5.0.5(default) matlab/R2016b(default)
altair-hwsolvers/14.0.210 gnuplot/5.0.5-x11 matlab/R2018a
amber/16 gromacs/2016.3(default) meqtrees/1.5.1(default)
anaconda/python2(default) gromacs/2018.3 mercurial/3.9.1(default)
anaconda/python3 gsl/2.5-gcc6(default) miniconda/python2
ansys/17.2 hdf5parallel/1.10.1-gcc6-mpt214 miniconda/python3
ansys/18.0 hdf5parallel/1.10.1-intel17-intel-mpi molpro/2012.1.22(default)
ansys/19.0 hdf5parallel/1.10.1-intel17-mpt214 mpt/2.14
blast/2.7.1+(default) intel-cc-16/16.0.2.181 mpt/2.17
casa/5.4.0(default) intel-cc-16/16.0.3.210(default) namd/2.12(default)
casacore/2.4.1(default) intel-cc-17/17.0.2.174(default) nano/2.6.3
castep/16.11 intel-cc-18/18.0.5.274 ncl/6.4.0
castep/18.1.0-intel17(default) intel-cmkl-16/16.0.2.181 nco/4.6.9
cmake/3.10.0(default) intel-cmkl-16/16.0.3.210(default) ncview/2.1.7
cp2k/4.1 intel-cmkl-17/17.0.2.174(default) netcdf/4.4.1
cp2k-mpt/4.1 intel-cmkl-18/18.0.5.274 netcdf-parallel/4.5.0
cuda/9.0 intel-compilers-16/16.0.2.181 netcdf-parallel/4.5.0-gcc6-mpt214
cuda/9.1(default) intel-compilers-16/16.0.3.210(default) netcdf-parallel/4.5.0-intel17
dolfin/2017.1.0(default) intel-compilers-17/17.0.2.174(default) netcdf-parallel/4.5.0-intel17-mpt214
dolfin/2017.1.0-python-2.7 intel-compilers-18/18.05.274 openfoam/foundation/5.0
dolfin/2017.2.0 intel-fc-16/16.0.2.181 openfoam/v1706
dolfin/2017.2.0-intel-mpi intel-fc-16/16.0.3.210(default) openfoam/v1712
dolfin/2017.2.0-mpt intel-fc-17/17.0.2.174(default) petsc/3.8.4-intel-mpi
dolfin/2018.1.0-intel-mpi intel-fc-18/18.0.5.274 petsc/3.8.4-mpt
doxygen/1.8.14(default) intel-itac/9.1.2.024 qe/6.1(default)
eclipse/4.2 intel-itac-17/2017.2.028(default) qe/6.1+d3q
epcc-tools/1.1(default) intel-itac-18/2018.5.025 R/3.4.0(default)
fenics/2016.2.0(default) intel-mpi-16/16.0.3.210 scalasca/2.3.1-gcc6
fenics/2017.2.0 intel-mpi-17/17.0.2.174 scalasca/2.3.1-intel17
fenics/2017.2.0-intel-mpi intel-mpi-18/18.0.5.274 singularity/2.4(default)
fenics/2017.2.0-mpt intel-tbb/16.0.2.181 sionlib/1.7.2-gcc6-mpt214
fenics/2018.1.0-intel-mpi intel-tbb/16.0.3.210(default) spack/20161205
fftw/3.3.5-gcc6 intel-tbb-17/17.0.2.174(default) spack/cirrus(default)
fftw/3.3.5-intel17 intel-tbb-18/18.0.5.274 spark/2.1.1(default)
flacs/10.5.1 intel-tools-16/16.0.2.181 starccm+/12.04.011(default)
flacs/10.6.3 intel-tools-16/16.0.3.210(default) starccm+/12.04.011-R8
gaussian/09.E01 intel-tools-17/17.0.2.174(default) szip/2.1.1
gaussian/16.A03(default) intel-tools-18/18.0.5.274 testing/qe/6.1-intel
gcc/6.2.0 intel-vtune-16/2016.2.0.444464 tinker/8.2.1
gcc/6.3.0(default) intel-vtune-16/2016.3.0.463186(default) valgrind/3.11.0
gcc/7.2.0 intel-vtune-17/2017.2.0.499904(default) vasp/5.4.4-intel17-mpt214(default)
gcc/8.2.0 intel-vtune-18/2018.4.0.573462 xflow/98.00
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@cirrus-login0 ~]$ which python3
/usr/bin/which: no python3 in (/lustre/home/z04/aturner/miniconda2/bin:/opt/sgi/sbin:/opt/sgi/bin:/usr/lib64/qt-3.3/bin:/opt/pbs/default/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/c3/bin:/sbin:/bin:/lustre/home/z04/aturner/bin)
We can load the python3
command with module load
:
[yourUsername@cirrus-login0 ~]$ module load anaconda/python3
[yourUsername@cirrus-login0 ~]$ which python3
/lustre/sw/anaconda/anaconda3-5.1.0/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@cirrus-login0 ~]$ echo $PATH
/lustre/home/z04/aturner/miniconda2/bin:/opt/sgi/sbin:/opt/sgi/bin:/usr/lib64/qt-3.3/bin:/opt/pbs/default/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/c3/bin:/sbin:/bin:/lustre/home/z04/aturner/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@cirrus-login0 ~]$ ls /lustre/sw/anaconda/anaconda3-5.1.0/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 it’s 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 abinit
module and then use the module list
command to show
which modules we currently have loaded in our environment. (Abinit is an open source
materials science modelling software package.)
[yourUsername@cirrus-login0 ~]$ module load abinit
[yourUsername@cirrus-login0 ~]$ module list
Currently Loaded Modulefiles:
1) anaconda/python3 5) intel-compilers-17/17.0.2.174 9) netcdf/4.4.1
2) mpt/2.16 6) intel-cmkl-17/17.0.2.174 10) abinit/8.2.3-intel17-mpt214
3) intel-cc-17/17.0.2.174 7) gcc/6.2.0
4) intel-fc-17/17.0.2.174 8) fftw-3.3.5-intel-17.0.2-dxt2dzn
So in this case, loading the abinit
module
also loaded a variety of other modules.
Let’s try unloading the abinit
package.
[yourUsername@cirrus-login0 ~]$ module unload abinit
[yourUsername@cirrus-login0 ~]$ module list
Currently Loaded Modulefiles:
1) anaconda/python3
So using module unload
“un-loads” a module along with it’s dependencies.
If we wanted to unload everything at once, we could run module purge
(unloads everything).
[yourUsername@cirrus-login0 ~]$ module load abinit
[yourUsername@cirrus-login0 ~]$ module purge
No Modulefiles Currently Loaded.
Note that module purge
has removed the anaconda/python3
module as well as abinit
and its dependencies.
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@cirrus-login0 ~]$ module avail
---------------------------------------------- /usr/share/Modules/modulefiles ----------------------------------------------
dot module-git module-info modules mpt/2.16 null perfboost perfcatcher use.own
-------------------------------------------------- /lustre/sw/modulefiles --------------------------------------------------
abinit/8.2.3-intel17-mpt214(default) gdal/2.1.2-gcc6 ipm/2.0.6-impi
allinea/7.0.0(default) gnu-parallel/20170322(default) lammps/31Mar2017-gcc6-mpt214(default)
altair-hwsolvers/13.0.213 gnuplot/5.0.5(default) matlab/R2016b(default)
altair-hwsolvers/14.0.210 gnuplot/5.0.5-x11 matlab/R2018a
amber/16 gromacs/2016.3(default) meqtrees/1.5.1(default)
anaconda/python2(default) gromacs/2018.3 mercurial/3.9.1(default)
anaconda/python3 gsl/2.5-gcc6(default) miniconda/python2
ansys/17.2 hdf5parallel/1.10.1-gcc6-mpt214 miniconda/python3
ansys/18.0 hdf5parallel/1.10.1-intel17-intel-mpi molpro/2012.1.22(default)
ansys/19.0 hdf5parallel/1.10.1-intel17-mpt214 mpt/2.14
blast/2.7.1+(default) intel-cc-16/16.0.2.181 mpt/2.17
casa/5.4.0(default) intel-cc-16/16.0.3.210(default) namd/2.12(default)
casacore/2.4.1(default) intel-cc-17/17.0.2.174(default) nano/2.6.3
castep/16.11 intel-cc-18/18.0.5.274 ncl/6.4.0
castep/18.1.0-intel17(default) intel-cmkl-16/16.0.2.181 nco/4.6.9
cmake/3.10.0(default) intel-cmkl-16/16.0.3.210(default) ncview/2.1.7
cp2k/4.1 intel-cmkl-17/17.0.2.174(default) netcdf/4.4.1
cp2k-mpt/4.1 intel-cmkl-18/18.0.5.274 netcdf-parallel/4.5.0
cuda/9.0 intel-compilers-16/16.0.2.181 netcdf-parallel/4.5.0-gcc6-mpt214
cuda/9.1(default) intel-compilers-16/16.0.3.210(default) netcdf-parallel/4.5.0-intel17
dolfin/2017.1.0(default) intel-compilers-17/17.0.2.174(default) netcdf-parallel/4.5.0-intel17-mpt214
dolfin/2017.1.0-python-2.7 intel-compilers-18/18.05.274 openfoam/foundation/5.0
dolfin/2017.2.0 intel-fc-16/16.0.2.181 openfoam/v1706
dolfin/2017.2.0-intel-mpi intel-fc-16/16.0.3.210(default) openfoam/v1712
dolfin/2017.2.0-mpt intel-fc-17/17.0.2.174(default) petsc/3.8.4-intel-mpi
dolfin/2018.1.0-intel-mpi intel-fc-18/18.0.5.274 petsc/3.8.4-mpt
doxygen/1.8.14(default) intel-itac/9.1.2.024 qe/6.1(default)
eclipse/4.2 intel-itac-17/2017.2.028(default) qe/6.1+d3q
epcc-tools/1.1(default) intel-itac-18/2018.5.025 R/3.4.0(default)
fenics/2016.2.0(default) intel-mpi-16/16.0.3.210 scalasca/2.3.1-gcc6
fenics/2017.2.0 intel-mpi-17/17.0.2.174 scalasca/2.3.1-intel17
fenics/2017.2.0-intel-mpi intel-mpi-18/18.0.5.274 singularity/2.4(default)
fenics/2017.2.0-mpt intel-tbb/16.0.2.181 sionlib/1.7.2-gcc6-mpt214
fenics/2018.1.0-intel-mpi intel-tbb/16.0.3.210(default) spack/20161205
fftw/3.3.5-gcc6 intel-tbb-17/17.0.2.174(default) spack/cirrus(default)
fftw/3.3.5-intel17 intel-tbb-18/18.0.5.274 spark/2.1.1(default)
flacs/10.5.1 intel-tools-16/16.0.2.181 starccm+/12.04.011(default)
flacs/10.6.3 intel-tools-16/16.0.3.210(default) starccm+/12.04.011-R8
gaussian/09.E01 intel-tools-17/17.0.2.174(default) szip/2.1.1
gaussian/16.A03(default) intel-tools-18/18.0.5.274 testing/qe/6.1-intel
gcc/6.2.0 intel-vtune-16/2016.2.0.444464 tinker/8.2.1
gcc/6.3.0(default) intel-vtune-16/2016.3.0.463186(default) valgrind/3.11.0
gcc/7.2.0 intel-vtune-17/2017.2.0.499904(default) vasp/5.4.4-intel17-mpt214(default)
gcc/8.2.0 intel-vtune-18/2018.4.0.573462 xflow/98.00
Let’s take a closer look at the gcc
module.
GCC is an extremely widely used C/C++/Fortran compiler.
Lots of software is dependent on the GCC version,
and might not compile or run if the wrong version is loaded.
In this case, there are three different versions: gcc/6.2.0
, gcc/6.3.0
and gcc/7.2.0
.
How do we load each copy and which copy is the default?
In this case, gcc/6.2.0
has a (default)
next to it.
This indicates that it is the default -
if we type module load gcc
, this is the copy that will be loaded.
[yourUsername@cirrus-login0 ~]$ module load gcc
[yourUsername@cirrus-login0 ~]$ gcc --version
gcc (GCC) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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 three GCC modules: gcc/6.2.0
, gcc/6.3.0
and gcc/7.2.0
To load a non-default module, we need to make add the version number after the /
in our module load
command
[yourUsername@cirrus-login0 ~]$ module load gcc/7.2.0
gcc/7.2.0(17):ERROR:150: Module 'gcc/7.2.0' conflicts with the currently loaded module(s) 'gcc/6.2.0'
gcc/7.2.0(17):ERROR:102: Tcl command execution failed: conflict gcc
What happened? The module command is telling us that we cannot have two gcc
modules loaded at the
same time as this could cause confusion about which version you are using. We need to remove the
default version before we load the new version.
[yourUsername@cirrus-login0 ~]$ module unload gcc
[yourUsername@cirrus-login0 ~]$ module load gcc/7.2.0
[yourUsername@cirrus-login0 ~]$ gcc --version
gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
We now have successfully switched from GCC 6.2.0 to GCC 7.2.0.
As switching between different versions of the same module is often used you can use module swap
rather than unloading one version before loading another. The equivalent of the steps above would be:
[yourUsername@cirrus-login0 ~]$ module purge
[yourUsername@cirrus-login0 ~]$ module load gcc
[yourUsername@cirrus-login0 ~]$ gcc --version
[yourUsername@cirrus-login0 ~]$ module swap gcc gcc/7.2.0
[yourUsername@cirrus-login0 ~]$ gcc --version
gcc (GCC) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This achieves the same result as unload followed by load but in a single step.
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 worker node).
Loading a module by default
Adding a set of
module load
commands to all of your scripts and having to manually load modules every time you log on can be tiresome. Fortunately, there is a way of specifying a set of “default modules” that always get loaded, regardless of whether or not you’re logged on or running a job.Every user has two hidden files in their home directory:
.bashrc
and.bash_profile
(you can see these files withls -la ~
). These scripts are run every time you log on or run a job. Adding amodule load
command to one of these shell scripts means that that module will always be loaded. Modify either your.bashrc
or.bash_profile
scripts to load a commonly used module like Python. Does yourpython3 --version
job from before still needmodule load
to run?
Installing software of our own
Most HPC systems 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@cirrus-login0 ~]$ git clone https://github.com/lh3/seqtk.git
Cloning into 'seqtk'...
remote: Counting objects: 316, done.
remote: Total 316 (delta 0), reused 0 (delta 0), pack-reused 316
Receiving objects: 100% (316/316), 141.52 KiB | 0 bytes/s, done.
Resolving deltas: 100% (181/181), 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@cirrus-login0 ~]$ cd seqtk
[yourUsername@cirrus-login0 ~]$ make
gcc -g -Wall -O2 -Wno-unused-function seqtk.c -o seqtk -lz -lm
seqtk.c: In function ‘stk_comp’:
seqtk.c:399: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@cirrus-login0 ~]$ ./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
We’ve successfully installed our first piece of software!
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.