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 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, the null module is a special module that is automatically loaded as a placeholder if automatic loading is
performed.
[yourUsername@cl1 ~]$ module list
Currently Loaded Modulefiles:
1) null
Listing available modules
To see available software modules, use module avail
[yourUsername@cl1 ~]$ module avail
------------------------- /apps/local/modules/biology --------------------------
rosetta/2020.11
----------------------- /apps/local/modules/environment ------------------------
openifs/40r1
------------------------ /apps/local/modules/materials -------------------------
ansys/18.2
------------------------- /apps/local/modules/physics --------------------------
comsol/1068666/5.5 star-ccm-plus/2019.1.1
comsol/all_licences/5.5 star-ccm-plus/2019.3
[removed most of the output her for clarity]
There is also the possibility of loading inherited modules from old systems such as Raven and HPC Wales but this is not
recommended and was only used to aide migration to Hawk. Loading either raven and hpcw modules will
change the available modules.
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@cl1 ~]$ which python3
/usr/bin/which: no python3 in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/c.username/bin)
We can load the python3 command with module load:
[yourUsername@cl1 ~]$ module load python
[yourUsername@cl1 ~]$ which python3
/apps/languages/python/3.7.0/el7/AVX512/intel-2018/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@cl1 ~]$ echo $PATH
/apps/languages/python/3.7.0/el7/AVX512/intel-2018/bin:/apps/compilers/intel/2018.2/compilers_and_libraries_2018/linux/bin/intel64:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/c.username/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@cl1 ~]$ ls /apps/languages/python/3.7.0/el7/AVX512/intel-2018/bin
2to3 f2py nosetests-3.4 python3
2to3-3.7 idle3 pip python3.7
chardetect idle3.7 pip3 python3.7-config
cygdb iptest pip3.7 python3.7m
cython iptest3 pydoc3 python3.7m-config
cythonize ipython pydoc3.7 python3-config
doesitcache ipython3 pygmentize pyvenv
easy_install natsort pytest pyvenv-3.7
easy_install-3.7 nosetests py.test wheel
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@cl1 ~]$ module list
Currently Loaded Modulefiles:
1) system/auto 3) python/3.7.0
2) compiler/intel/2018/2
[yourUsername@cl1 ~]$ module load plink
[yourUsername@cl1 ~]$ module list
Currently Loaded Modulefiles:
1) system/auto 4) mkl/2018/3
2) compiler/intel/2018/2 5) plink/2.0
3) python/3.7.0
So in this case, loading the plink module (a bioinformatics software package), also loaded
mkl/2018/3 as well. Let’s try unloading the plink package.
[yourUsername@cl1 ~]$ module unload plink
[yourUsername@cl1 ~]$ module list
Currently Loaded Modulefiles:
1) system/auto 3) mkl/2018/3
2) compiler/intel/2018/3 4) python/3.7.0
So using module unload “un-loads” a module but NOT its dependencies.
If we wanted to unload everything at once, we could run module purge (unloads everything).
[yourUsername@cl1 ~]$ module purge
[yourUsername@cl1 ~]$ module list
No Modulefiles Currently Loaded.
Note is has unloaded everything, including the original null package that was used as a placeholder for
initialisation.
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@cl1 ~]$ module avail
------------------------- /apps/local/modules/biology --------------------------
rosetta/2020.11
----------------------- /apps/local/modules/environment ------------------------
openifs/40r1
------------------------ /apps/local/modules/materials -------------------------
ansys/18.2
------------------------- /apps/local/modules/physics --------------------------
comsol/1068666/5.5 star-ccm-plus/2019.1.1
comsol/all_licences/5.5 star-ccm-plus/2019.3
[removed most of the output her for clarity]
Let’s take a closer look at the compiler/gnu 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 versions from: compiler/gnu/4/8.5 to
compiler/gcc/9/2.0. How do we load each copy and which copy is the default?
In this case, compiler/gcc/9/2.0 is the latest version. This indicates that it is the default - if we type
module load compiler/gnu, this is the copy that will be loaded.
[yourUsername@cl1 ~]$ module load compiler/gnu
[yourUsername@cl1 ~]$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 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 module system just loaded the GCC compilers into the environment, you can mix multiple compilers (if Intel C++ requires a recent GCC compiler for C++ compatability) it can be done. Some other module systems have more login available to automatically unload modules if conflicts are detected but not currently used on Hawk.
Now lets switch to a new compiler. Either using:
[yourUsername@cl1 ~]$ module unload compiler
[yourUsername@cl1 ~]$ module load compiler/gnu/4/8.5
[yourUsername@cl1 ~]$ module list
[yourUsername@cl1 ~]$ gcc --version
Alternatively using the module switch command.
[yourUsername@cl1 ~]$ module switch compiler/gnu/4/8.5
Currently Loaded Modulefiles:
1) system/auto 2) compiler/gnu/4/8.5
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 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 9.2.0 to GCC 4.8.5.
Some modules have (default) at the end of the module listing in avail. For example for python
[yourUsername@cl1 ~]$ module avail python
--------------------------- /apps/modules/languages ----------------------------
python/3.5.9 python/3.7.7-intel2020u1 python-numpy/1.14.5
python/3.6.3-intel2018u3 python-h5py/2.8.0 python-pyside/1.2.4
python/3.6.9-intel2019u5 python-matplotlib/2.2.2 python-scipy/1.1.0
python/3.7.0(default) python-mayavi/4.6.0 python-vtk/8.1.0
In this case python/3.7.0 is the default package.
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). Runningmodule purgeas first command in the job is recommended.
Loading a module by default
Adding a set of
module loadcommands 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:.bashrcand.bash_profile(you can see these files withls -la ~). These scripts are run every time you log on or run a job. To aide with changes to the system, a.myenvfile is sourced by.bashrc. Adding amodule loadcommand to.myenvmeans that that module will always be loaded. Modify either your.myenvscripts to load a commonly used module like Python. Does yourpython3 --versionjob from before still needmodule loadto 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@cl1 ~]$ 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@cl1 ~]$ cd seqtk
[yourUsername@cl1 ~]$ 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@cl1 ~]$ ./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
Discover available software with
module availLoad software with
module load softwareNameUnload software with
module purgeThe module system handles software versioning and package conflicts for you automatically.