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.
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 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 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 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 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@login-2.SAGA ~]$ module list
No Modulefiles Currently Loaded.
Listing available modules
To see available software modules, use module avail
[yourUsername@login-2.SAGA ~]$ module avail
[user@login-1.SAGA ~/jobs/teaching]$ module avail
----------- /cluster/modulefiles/all ---------------------
ABySS/2.0.2-gompi-2019a gompi/2019b OpenMPI/3.1.3-gcccuda-2019a
AdapterRemoval/2.3.1-foss-2018b gompi/2019b OpenMPI/3.1.4-GCC-8.3.0
AdapterRemoval/2.3.1-GCC-8.2.0-2.3.1 gompic/2018b OpenMPI/3.1.4-gcccuda-2019b
ADF/2019.103+StaticMKL gompic/2019a OpenMPI/3.1.4-PGI-19.9-GCC-8.3.0
AdmixTools/5.1-GCC-7.3.0-2.30 gompic/2019b ORCA/4.2.0-gompi-2019b
ADMIXTURE/1.3.0 GROMACS/2018.1-foss-2018b OrthoMCL/2.0.9-intel-2018b-Perl-5.28.0
Anaconda3/2019.03 GROMACS/2019.4-foss-2019b PAML/4.9i-GCC-7.3.0-2.30
........
........
.......
Where:
S: Module is Sticky, requires --force to unload or purge
L: Module is loaded
Aliases: 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.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
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@login-2.SAGA ~]$ which python3
/usr/bin/which:no python3 in
/usr/bin/which: no python3 in (/node/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/cluster/bin:/cluster/home/sabryr/.local/bin:/cluster/home/sabryr/bin)
We can load the python3
command with module load
:
[yourUsername@login-2.SAGA ~]$ module load python
[yourUsername@login-2.SAGA ~]$ which python3
/cluster/software/Python/3.6.6-foss-2018b/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@login-2.SAGA ~]$ echo $PATH
/cluster/software/Python/3.6.6-foss-2018b/bin:/cluster/software/XZ/5.2.4-GCCcore-7.3.0/bin:/cluster/software/libreadline/7.0-GCCcore-7.3.0/bin:/cluster/software/ncurses/6.1-GCCcore-7.3.0/bin:/cluster/software/bzip2/1.0.6-GCCcore-7.3.0/bin:/cluster/software/FFTW/3.3.8-gompi-2018b/bin:/cluster/software/OpenBLAS/0.3.1-GCC-7.3.0-2.30/bin:/cluster/software/OpenMPI/3.1.1-GCC-7.3.0-2.30/bin:/cluster/software/hpcx/2.4/clusterkit/bin:/cluster/software/hpcx/2.4/bupc/bin:/cluster/software/hpcx/2.4/hcoll/bin:/cluster/software/hpcx/2.4/ucx/mt/bin:/cluster/software/binutils/2.30-GCCcore-7.3.0/bin:/cluster/software/GCCcore/7.3.0/bin:/node/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/cluster/bin:/cluster/home/sabryr/.local/bin:/cluster/home/sabryr/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@login-2.SAGA ~]$ ls /cluster/software/Python/3.6.6-foss-2018b/bin
2to3 cygdb easy_install-3.6 ffc-3 instant-clean nosetests pip3 python python3.6m pyvenv-3.6 ufl-analyse
2to3-3.6 cython eggs from-template instant-showcache nosetests-3.6 pip3.6 python3 python3.6m-config runxlrd.py ufl-convert
chardetect cythonize f2py idle3 isympy pbr pydoc3 python3.6 python3-config tabulate ufl-version
conv-template easy_install ffc idle3.6 netaddr pip pydoc3.6 python3.6-config pyvenv ufl2py virtualenv
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 use module list
. module list
shows all loaded software modules.
[yourUsername@login-2.SAGA ~]$ module list
Currently Loaded Modules:
1) StdEnv (S) 6) hpcx/2.4 11) ScaLAPACK/2.0.2-gompi-2018b-OpenBLAS-0.3.1 16) XZ/5.2.4-GCCcore-7.3.0 (H)
2) GCCcore/7.3.0 7) OpenMPI/3.1.1-GCC-7.3.0-2.30 12) foss/2018b 17) GMP/6.1.2-GCCcore-7.3.0 (H)
3) zlib/1.2.11-GCCcore-7.3.0 (H) 8) OpenBLAS/0.3.1-GCC-7.3.0-2.30 13) bzip2/1.0.6-GCCcore-7.3.0 (H) 18) libffi/3.2.1-GCCcore-7.3.0 (H)
4) binutils/2.30-GCCcore-7.3.0 (H) 9) gompi/2018b 14) ncurses/6.1-GCCcore-7.3.0 (H) 19) Python/3.6.6-foss-2018b
5) GCC/7.3.0-2.30 10) FFTW/3.3.8-gompi-2018b 15) libreadline/7.0-GCCcore-7.3.0 (H)
Where:
S: Module is Sticky, requires --force to unload or purge
H: Hidden Module
[yourUsername@login-2.SAGA ~]$ module restore
[yourUsername@login-2.SAGA ~]$ module load GATK/4.1.4.0-GCCcore-8.3.0-Java-1.8
[yourUsername@login-2.SAGA ~]$ module list
Currently Loaded Modules:
1) StdEnv (S) 4) zlib/1.2.11-GCCcore-8.3.0 (H) 7) ncurses/6.1-GCCcore-8.3.0 (H) 10) GMP/6.1.2-GCCcore-8.3.0 (H) 13) GATK/4.1.4.0-GCCcore-8.3.0-Java-1.8
2) GCCcore/8.3.0 5) binutils/2.32-GCCcore-8.3.0 (H) 8) libreadline/8.0-GCCcore-8.3.0 (H) 11) libffi/3.2.1-GCCcore-8.3.0 (H)
3) Java/1.8.0_212 6) bzip2/1.0.8-GCCcore-8.3.0 (H) 9) XZ/5.2.4-GCCcore-8.3.0 (H) 12) Python/3.7.4-GCCcore-8.3.0
Where:
S: Module is Sticky, requires --force to unload or purge
H: Hidden Module
So in this case, loading the GATK
module (a bioinformatics software package), also loaded
java/1.8.0_212
and Python/3.7.4-GCCcore-8.3.0
as well.
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
or module restore
(unloads everything).
[yourUsername@login-2.SAGA ~]$ module purge
The following modules were not unloaded:
(Use "module --force purge" to unload all):
1) StdEnv
Note that module purge
is informative. It lets us know that all but a default set of packages
have been unloaded (and how to actually unload these if we truly so desired).
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@login-2.SAGA ~]$ module avail
[user@login-1.SAGA ~/jobs/teaching]$ module avail
----------- /cluster/modulefiles/all ---------------------
ABySS/2.0.2-gompi-2019a gompi/2019b OpenMPI/3.1.3-gcccuda-2019a
AdapterRemoval/2.3.1-foss-2018b gompi/2019b OpenMPI/3.1.4-GCC-8.3.0
AdapterRemoval/2.3.1-GCC-8.2.0-2.3.1 gompic/2018b OpenMPI/3.1.4-gcccuda-2019b
ADF/2019.103+StaticMKL gompic/2019a OpenMPI/3.1.4-PGI-19.9-GCC-8.3.0
AdmixTools/5.1-GCC-7.3.0-2.30 gompic/2019b ORCA/4.2.0-gompi-2019b
ADMIXTURE/1.3.0 GROMACS/2018.1-foss-2018b OrthoMCL/2.0.9-intel-2018b-Perl-5.28.0
Anaconda3/2019.03 GROMACS/2019.4-foss-2019b PAML/4.9i-GCC-7.3.0-2.30
........
........
.......
Where:
S: Module is Sticky, requires --force to unload or purge
L: Module is loaded
Aliases: 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.
Use "module keyword key1 key2 ..." to search for all possible modules matching any of the "keys".
Let’s take a closer look at the gcc
module. GCC is an extremely widely used C/C++/Fortran
compiler. Tons 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 two different versions: GCC/7.3.0-2.30
and
GCC/8.2.0-2.31.1
. How do we load each copy and which copy is the default?
On saga you must specify the version of the package you want to load
[yourUsername@login-2.SAGA ~]$ module load gcc
Lmod has detected the following error: The following module(s) are unknown: "gcc"
[yourUsername@login-2.SAGA ~]$ module load GCC/8.2.0-2.31.1
[yourUsername@login-2.SAGA ~]$ module list
Currently Loaded Modules:
1) StdEnv (S) 2) GCCcore/7.3.0 3) zlib/1.2.11-GCCcore-7.3.0 (H) 4) binutils/2.30-GCCcore-7.3.0 (H) 5) GCC/7.3.0-2.30
Where:
S: Module is Sticky, requires --force to unload or purge
H: Hidden Module
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).
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@login-2.SAGA ~]$ 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@login-2.SAGA ~]$ cd seqtk
[yourUsername@login-2.SAGA ~]$ 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@login-2.SAGA ~]$ ./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.
You can edit your
.bashrc
file to automatically load a software package.