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@eslogin001:~> module list
Currently Loaded Modulefiles:
1) modules/3.2.10.6
2) eswrap/1.3.3-1.020200.1280.0
3) switch/1.0-1.0502.60522.1.61.ari
4) cce/8.5.8
5) craype-network-aries
6) craype/2.5.10
7) cray-libsci/16.11.1
8) udreg/2.3.2-1.0502.10518.2.17.ari
9) ugni/6.0-1.0502.10863.8.29.ari
10) pmi/5.0.12
11) dmapp/7.0.1-1.0502.11080.8.76.ari
12) gni-headers/4.0-1.0502.10859.7.8.ari
13) xpmem/0.1-2.0502.64982.5.3.ari
14) dvs/2.5_0.9.0-1.0502.2188.1.116.ari
15) alps/5.2.4-2.0502.9774.31.11.ari
16) rca/1.0.0-2.0502.60530.1.62.ari
17) atp/2.1.0
18) PrgEnv-cray/5.2.82
19) pbs/13.0.412.192482
20) craype-ivybridge
21) cray-mpich/7.5.5
22) packages-archer
23) bolt/0.6
24) nano/2.2.6
25) leave_time/1.3.0
26) quickstart/1.0
27) ack/2.14
28) openssl/1.1.0g_build1
29) curl/7.58.0_build1
30) git/2.16.2_build1
31) wget/1.19.4
32) epcc-tools/9.0
Listing available modules
To see available software modules, use module avail
yourUsername@eslogin001:~> module avail
--------------------- /opt/cray/craype/2.5.10/modulefiles ----------------------
craype-accel-host craype-hugepages4M craype-hugepages512M
craype-accel-nvidia20 craype-hugepages8M craype-intel-knc
craype-accel-nvidia35 craype-hugepages16M craype-ivybridge
craype-accel-nvidia60 craype-hugepages32M craype-mic-knl
craype-broadwell craype-hugepages64M craype-network-aries
craype-haswell craype-hugepages128M craype-network-none
craype-hugepages2M craype-hugepages256M craype-sandybridge
---------------------------- /opt/cray/modulefiles -----------------------------
PrgEnv-cray/5.1.29
PrgEnv-cray/5.2.56
PrgEnv-cray/5.2.82(default)
PrgEnv-gnu/5.1.29
PrgEnv-gnu/5.2.56
PrgEnv-gnu/5.2.82(default)
PrgEnv-intel/5.1.29
PrgEnv-intel/5.2.56
PrgEnv-intel/5.2.82(default)
atp/1.7.5
atp/1.8.3
atp/2.1.0(default)
atp/2.1.0_debug
atp/2.1.1
atp/2.1.1_debug
atp/2.1.3
atp/2.1.3_debug
capmc/1.0-1.0702.37257.16.1(default)
ccm/2.2.0-1.0500.43485.5.54
ccm/2.2.0-1.0501.48422.4.56
...
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@eslogin001:~> which python3
which: no python3 in (/home/y07/y07/cse/epcc-archer-tools/bin:/home/y07/y07/cse/wget/wget-1.19.4/build/bin:/home/y07/y07/cse/git/git-2.16.2_build1/install/bin:/home/y07/y07/cse/curl/curl-7.58.0_build1/install/bin:/home/y07/y07/cse/openssl/openssl-1.1.0g_build1/install/bin:/usr/local/packages/cse/ack:/usr/local/packages/cse/quickstart/1.0:/home/y07/y07/cse/leave_time/1.3.0:/home/y07/y07/cse/nano/2.2.6/bin:/usr/local/packages/cse/bolt/0.6/bin:/opt/cray/mpt/7.5.5/gni/bin:/opt/pbs/13.0.412.192482/bin:/opt/cray/rca/1.0.0-2.0502.60530.1.62.ari/bin:/opt/cray/alps/5.2.4-2.0502.9774.31.11.ari/sbin:/opt/cray/dvs/2.5_0.9.0-1.0502.2188.1.116.ari/bin:/opt/cray/xpmem/0.1-2.0502.64982.5.3.ari/bin:/opt/cray/ugni/6.0-1.0502.10863.8.29.ari/bin:/opt/cray/udreg/2.3.2-1.0502.10518.2.17.ari/bin:/opt/cray/craype/2.5.10/bin:/opt/cray/cce/8.5.8/cray-binutils/x86_64-pc-linux-gnu/bin:/opt/cray/cce/8.5.8/craylibs/x86-64/bin:/opt/cray/cce/8.5.8/cftn/bin:/opt/cray/cce/8.5.8/CC/bin:/opt/cray/switch/1.0-1.0502.60522.1.61.ari/bin:/opt/cray/eslogin/eswrap/1.3.3-1.020200.1280.0/bin:/opt/modules/3.2.10.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/sbin:/usr/sbin:.:/usr/lib/qt3/bin:/opt/cray/bin)
We can load the python3
command with module load
:
[yourUsername@eslogin001 ~]$ module load anaconda/python3
[yourUsername@eslogin001 ~]$ which python3
/home/y07/y07/cse/anaconda/python3/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@eslogin001:~> echo $PATH
/home/y07/y07/cse/anaconda/python3/bin:/home/y07/y07/cse/epcc-archer-tools/bin:/home/y07/y07/cse/wget/wget-1.19.4/build/bin:/home/y07/y07/cse/git/git-2.16.2_build1/install/bin:/home/y07/y07/cse/curl/curl-7.58.0_build1/install/bin:/home/y07/y07/cse/openssl/openssl-1.1.0g_build1/install/bin:/usr/local/packages/cse/ack:/usr/local/packages/cse/quickstart/1.0:/home/y07/y07/cse/leave_time/1.3.0:/home/y07/y07/cse/nano/2.2.6/bin:/usr/local/packages/cse/bolt/0.6/bin:/opt/cray/mpt/7.5.5/gni/bin:/opt/pbs/13.0.412.192482/bin:/opt/cray/rca/1.0.0-2.0502.60530.1.62.ari/bin:/opt/cray/alps/5.2.4-2.0502.9774.31.11.ari/sbin:/opt/cray/dvs/2.5_0.9.0-1.0502.2188.1.116.ari/bin:/opt/cray/xpmem/0.1-2.0502.64982.5.3.ari/bin:/opt/cray/ugni/6.0-1.0502.10863.8.29.ari/bin:/opt/cray/udreg/2.3.2-1.0502.10518.2.17.ari/bin:/opt/cray/craype/2.5.10/bin:/opt/cray/cce/8.5.8/cray-binutils/x86_64-pc-linux-gnu/bin:/opt/cray/cce/8.5.8/craylibs/x86-64/bin:/opt/cray/cce/8.5.8/cftn/bin:/opt/cray/cce/8.5.8/CC/bin:/opt/cray/switch/1.0-1.0502.60522.1.61.ari/bin:/opt/cray/eslogin/eswrap/1.3.3-1.020200.1280.0/bin:/opt/modules/3.2.10.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/sbin:/usr/sbin:.:/usr/lib/qt3/bin:/opt/cray/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@eslogin001 ~]$ ls /home/y07/y07/cse/anaconda/python3/bin
[output truncated]
2to3
2to3-3.5
activate
activate-global-python-argcomplete
anaconda
anaconda-navigator
asadmin
assistant
binstar
blaze-server
bokeh
bokeh-server
bundle_image
cfadmin
conda
conda-build
conda-convert
conda-develop
conda-env
conda-index
conda-inspect
condamanager
conda-metapackage
conda-pipbuild
conda-render
conda-server
conda-sign
conda-skeleton
[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@eslogin001:~> module load abinit
yourUsername@eslogin001:~> module list
Currently Loaded Modulefiles:
Currently Loaded Modulefiles:
1) modules/3.2.10.6
2) eswrap/1.3.3-1.020200.1280.0
...
33) anaconda/python3
34) abinit/7.10.4
So in this case, loading the abinit
module
also loaded a variety of other modules.
Let’s try unloading the abinit
package.
yourUsername@eslogin001:~> module unload abinit
yourUsername@eslogin001:~> module list
Currently Loaded Modulefiles:
1) modules/3.2.10.6
2) eswrap/1.3.3-1.020200.1280.0
...
33) anaconda/python3
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
(unloads everything).
yourUsername@eslogin001:~> module load abinit
yourUsername@eslogin001:~> 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@eslogin001:~> module avail
--------------------- /opt/cray/craype/2.5.10/modulefiles ----------------------
craype-accel-host craype-hugepages4M craype-hugepages512M
craype-accel-nvidia20 craype-hugepages8M craype-intel-knc
craype-accel-nvidia35 craype-hugepages16M craype-ivybridge
craype-accel-nvidia60 craype-hugepages32M craype-mic-knl
craype-broadwell craype-hugepages64M craype-network-aries
craype-haswell craype-hugepages128M craype-network-none
craype-hugepages2M craype-hugepages256M craype-sandybridge
---------------------------- /opt/cray/modulefiles -----------------------------
PrgEnv-cray/5.1.29
PrgEnv-cray/5.2.56
PrgEnv-cray/5.2.82(default)
PrgEnv-gnu/5.1.29
PrgEnv-gnu/5.2.56
PrgEnv-gnu/5.2.82(default)
PrgEnv-intel/5.1.29
PrgEnv-intel/5.2.56
PrgEnv-intel/5.2.82(default)
atp/1.7.5
atp/1.8.3
atp/2.1.0(default)
atp/2.1.0_debug
atp/2.1.1
atp/2.1.1_debug
atp/2.1.3
atp/2.1.3_debug
capmc/1.0-1.0702.37257.16.1(default)
ccm/2.2.0-1.0500.43485.5.54
ccm/2.2.0-1.0501.48422.4.56
...
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.
There are many different versions and subversions: gcc/4.8.1
, gcc/6.3.0
, gcc/7.3.0
, …
How do we know what is available and which copy is the default?
You can look at the availabilty of different versions:
yourUsername@eslogin001:~> module avail gcc
------------------------------- /opt/modulefiles -------------------------------
gcc/4.8.1 gcc/5.1.0 gcc/6.3.0(default)
gcc/4.9.2 gcc/5.3.0 gcc/7.2.0
gcc/4.9.3 gcc/6.1.0 gcc/7.3.0
In this case, gcc/6.3.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@eslogin001:~> module load gcc
yourUsername@eslogin001:~> gcc --version
gcc (GCC) 6.3.0 20161221 (Cray Inc.)
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.
To load a non-default module, we need to make add the version number after the /
in our module load
command
yourUsername@eslogin001:~> module load gcc/7.3.0
gcc/7.3.0(3):ERROR:150: Module 'gcc/7.3.0' conflicts with the currently loaded module(s) 'gcc/6.3.0'
gcc/7.3.0(3):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@eslogin001:~> module unload gcc
yourUsername@eslogin001:~> module load gcc/7.3.0
yourUsername@eslogin001:~> gcc --version
gcc (GCC) 7.3.0 20180125 (Cray Inc.)
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.3.0 to GCC 7.3.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@eslogin001:~> module purge
yourUsername@eslogin001:~> module load gcc
yourUsername@eslogin001:~> gcc --version
yourUsername@eslogin001:~> module swap gcc gcc/7.3.0
yourUsername@eslogin001:~> gcc --version
gcc (GCC) 6.3.0 20161221 (Cray Inc.)
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.3.0 20180125 (Cray Inc.)
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 compute 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 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@eslogin001:~> module switch openssl openssl/1.1.1c_build1
yourUsername@eslogin001:~> 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@eslogin001:~> cd seqtk
yourUsername@eslogin001:~> 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@eslogin001:~> ./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.