This is an archived version of the course - please consider using the latest version.
4 Software Management
- Use the
moduletool to search for and load pre-installed software. - Describe what a package manager is, and how it can be used to manage software instalation on a HPC environment.
- Install the Mamba package manager.
- Create a software environment and install software using Mamba.
- Describe what a software container is and how it differs from a package manager.
- Download and use a pre-existing software container for bioinformatics and scientific computing applications.
4.1 Using pre-installed software
It is very often the case that HPC admins have pre-installed several software packages that are regularly used by their users. Because there can be a large number of packages (and often different versions of the same program), you need to load the programs you want to use in your script using the module tool.
The following table summarises the most common commands for this tool:
| Command | Description |
|---|---|
module avail |
List all available packages. |
module avail -a -i "pattern" or module avail | grep -i "pattern" |
Search the available package list that matches “pattern”. Note the second option is given as some versions of module do not support case-insensitive search (-i option). |
module load <program> |
Load the program and make it available for use. |
module unload <program> |
Unload the program (removes it from your PATH). |
For example, on our training HPC, you can try to run module avail to see which software is available. We can see an example using the software called bowtie2. If we try to use this software at the moment we get an error:
bowtie2 --versionCommand 'bowtie2' not found, but can be installed with:
apt install bowtie2
Please ask your administrator.
But if we load the software first, then the command works:
module load bowtie/2.5.0
bowtie2 --version/usr/local/Cluster-Apps/bowtie/2.5.0/bowtie2-align-s version 2.5.0
64-bit
Built on login-e-12
Mon 14 Nov 12:11:12 UTC 2022
Compiler: gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
Options: -O3 -msse2 -funroll-loops -g3 -std=c++11 -DPOPCNT_CAPABILITY -DNO_SPINLOCK -DWITH_QUEUELOCK=1
Sizeof {int, long, long long, void*, size_t, off_t}: {4, 8, 8, 8, 8, 8}
If you echo $PATH, you will notice the installer has been added to your PATH variable (the environment variable that tells the shell where to find programs to run). Once you run module unload bowtie2/2.5.0, and then echo $PATH again, you notice the PATH variable will have been modified. This is how the Environment Modules package makes software available for you to use.
If a package is not available through the module command, your only option is to contact the HPC admin and ask them to install it for you. Alternatively, you can use a package manager as we briefly explain in the next section.
4.2 Package managers
Often you may want to use software packages that are not be installed by default on the HPC. There are several ways you could manage your own software installation, one of the most popular ones being the use of the package manager Conda or its newer implementation Mamba.
Covering Conda/Mamba is out of the scope of these materials, but you may want to attend our accompanying course Managing bioinformatics software and pipelines to learn more about this topic.
Very briefly, you manage packages by encapsulating them in an environment, and then activating the environment to make the software available. For example, we can install the toy program called cowpy:
# Create an environment
mamba create -n cowpy
# Install the software
mamba install -n cowpy conda-forge::cowpy=1.1.5To use the packages installed in an environment, it needs to be activated:
mamba activate cowpyAn important note when working on a HPC is that you need to add some Mamba configuration commands before activating the environment. This would be our SLURM script:
#!/bin/bash
#SBATCH ... SLURM options here ...
# Always add these two commands when using mamba
eval "$(conda shell.bash hook)"
source $CONDA_PREFIX/etc/profile.d/mamba.sh
# then you can activate the environment
mamba activate cowpy
# the rest of your code...This is because when we submit jobs to SLURM the jobs will start in a non-interactive shell, and mamba doesn’t get automatically set. Running the commands shown will ensure mamba activate works as expected.
Although Mamba is a great tool to manage your own software installation, the disadvantage is that the software is not compiled specifically taking into account the hardware of the HPC. This is a slightly technical topic, but the main practical consequence is that software installed by HPC admins and made available through the module system may sometimes run faster than software installed via conda. This means you will use fewer resources and your jobs will complete faster.
Before you use Mamba, you will need to install it on the HPC. If you are attending our live course, we already have Mamba installed, so you can skip this step.
The default instructions below install Mamba on the user’s home. However, for Cambridge HPC users, we recommend installing Mamba on the fast storage partition called RDS.
Users from other institutions may want to adjust the dir_to_install variable given in the code block below, and install miniforge in a directory of their choice.
dir_to_install="$HOME/miniforge3"
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh -b -p $dir_to_install
rm Miniforge3-$(uname)-$(uname -m).sh
$dir_to_install/bin/mamba shell init --shell bashdir_to_install="$HOME/rds/hpc-work/miniforge3"
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh -b -p $dir_to_install
rm Miniforge3-$(uname)-$(uname -m).sh
$dir_to_install/bin/mamba shell init --shell bashLogout of the HPC and log back in again, to restart your terminal.
Then run the following commands:
conda config --add channels nodefaults
conda config --add channels bioconda
conda config --add channels conda-forge
conda config --set channel_priority strict
conda config --set remote_read_timeout_secs 1000The software installation “recipes” used by Mamba are maintained by large communities of software developers. These communities are organised by channels, i.e. software repositories. Two popular channels are:
- conda-forge - maintains several data science packages
- bioconda - maintains bioinformatics software
The setup instructions given above add these channels to our Mamba setup, so that it looks for software in those repositories by default.
4.3 Containers
Another option to run specialised software on a HPC is to run your commands within pre-built containers. Containers are a technology that can be used to create and manage computational environments. A container is a lightweight, standalone executable package that contains everything needed to run a piece of software, including the operating system, libraries, and application code. Containers are isolated from the host system, meaning that they can run the same software in different environments without conflicts or interference.
We will focus on one of the most popular container platforms for cluster systems: Singularity (also known as Apptainer). Singularity is a free and open-source computer program that performs operating-system-level virtualization also known as containerization. Singularity is also designed to create and manage isolated environments as Docker, which is another popular and widely used container platform (i.e. images created with docker can be compatible with Singularity and vice versa).
There are some key differences between Docker containers and Singularity containers. The most important being the necessary permission level of the containers. Docker containers run as root by default, which means that they have full access to the host system. While this can be advantageous in some cases, it can also pose security risks, particularly in multi-user environments. Singularity, on the other hand, runs containers as non-root users by default, which can improve security and prevent unauthorized access to the host system. Singularity is specifically designed for use in HPC environments and can run on a wide variety of platforms and systems without root access.
In summary:
- Docker is well-suited for building and distributing software across different platforms and operating systems
- Singularity is specifically designed for use in HPC environments and can provide improved security and performance in those settings.
4.3.1 Singularity installation
Typically, Singularity is pre-installed on HPC servers by the system administrators, and we recommend that you use the version installed by your system admins.
Although it is possible to install it yourself (e.g. with Mamba), we have found this to be a less reliable way to setup Singularity on a HPC. This is because it requires further configuration to interact with the filesystem (in particular as we submit jobs to SLURM).
4.3.2 Singularity images
Although you can build your own Singularity images, for many popular software there are already pre-built images available from public repositories. A very popular one being depot.galaxyproject.org maintained by the Galaxy project.
For example, let’s consider the SeqKit program, which is a toolkit for manipulating FASTA/Q files.
First, go to depot.galaxyproject.org and search for the software of interest (use Ctrl + F to find the text of interest).
When you find the software and version of interest, right-click the file and click “Copy Link”.
Then use that link with the
singularity pullcommand:# create a directory for our singularity images mkdir images # download the image singularity pull images/seqkit-2.8.0.sif https://depot.galaxyproject.org/singularity/seqkit%3A2.8.0--h9ee0642_0
Here, we are saving the image file as seqkit-2.8.0.sif (.sif is the standard extension for singularity images). Once we have this image available, we are ready to run the software, which will see in practice with the exercise below.
4.4 Exercises
4.5 Summary
- The
moduletool can be used to search for and load pre-installed software packages on a HPC.- This tool may not always be available on your HPC.
- To install your own software, you can use the Mamba package manager.
Mamba allows you to have separate “software environments”, where multiple package versions can co-exist on your system.
Use
mamba create -n ENVto create a new software environment andmamba install -n ENV PROGRAMto install a program on that environment.Use
mamba activate ENVto “activate” the software environment and make all the programs installed there available.When submitting jobs to
sbatch, remember to include the Mamba configuration commands at the start of your script:```bash eval "$(conda shell.bash hook)" source $CONDA_PREFIX/etc/profile.d/mamba.sh ```
- Software containers can be a reliable alternative to Mamba environments, with many pre-existing containers available at depot.galaxyproject.org.
- To download a software container from public repositories, use the
singularity pullcommand. - To run a command within the software container, use the
singularity runcommand.
- To download a software container from public repositories, use the

