Skip to content

Apptainer / Singularity

Overview

Apptainer (formerly known as Singularity) is a popular software package in the HPC world that allows researchers to utilize containers to run scientific programs, even if they haven't been natively installed by cluster administrators. Focused on portability and reproducibility, the goal of using systems such as Apptainer is to be able to take a program built on one system, and easily run it on another without having to worry about dependencies, libraries, or differences in output.

Using Apptainer also provides a path for researchers to tap into the existing Docker Hub repository for container images, or any system that follows the Open Containers Initiative (OCI) format.

Availability

Cluster Module/Version
BOSE apptainer/1.2.5
BGSC Not Available

Note: You can simply use module load apptainer to activate the most recently installed version of this software.

Example Use - PhyML

The following commands show how to run a containerized version of PhyML, a phylogenies program used in Biology.

It first loads the apptainer module on the cluster, then defines the path to an online container image for PhyML we want to work with. Finally, it runs the container image through Apptainer and provides access to the built-in executable "phyml" to simply report its version.

module load apptainer/latest
$CONTAINER="https://depot.galaxyproject.org/singularity/phyml%3A3.3.20220408--h37cc20f_1"
apptainer run $CONTAINER phyml --version

Sample Slurm Script

submit.sh
#!/bin/bash
# -- SLURM SETTINGS -- #
# [..] other settings here [..]

# The following settings are for the overall request to Slurm
#SBATCH --ntasks-per-node=4     # How many CPU cores do you want to request
#SBATCH --mem=5G                 # How much memory do you want to request?
#SBATCH --nodes=1                # How many nodes do you want to request

# -- SCRIPT COMMANDS -- #

# Load the needed modules
module load apptainer/latest    # Load Apptainer
apptainer exec my-container.sif my-binary

Sample Slurm Script (MPI)

mpi-submit.sh
#!/bin/bash
# -- SLURM SETTINGS -- #
# [..] other settings here [..]

# The following settings are for the overall request to Slurm
#SBATCH --ntasks-per-node=8     # How many CPU cores per node do you want to request
#SBATCH --mem=5G                 # How much memory per node do you want to request?
#SBATCH --nodes=2                # How many nodes do you want to request

# -- SCRIPT COMMANDS -- #

# Load the needed modules
module load apptainer/latest    # Load Apptainer
module load openmpi             # Load OpenMPI
mpirun -n $SLURM_NTASKS apptainer exec my-container.sif my-binary

Real Example

Has your research group used Apptainer in a project? Contact the HPC Team and we'd be glad to feature your work.

Citation

Please include the following citation in your papers to support continued development of Apptainer, which is referenced by its former name 'Singularity'.

Singularity Developers (2021) Singularity. 10.5281/zenodo.1310023 https://doi.org/10.5281/zenodo.1310023

The developers also shared the citation for Singularity's original publication, and ask that you also consider including it.

Kurtzer GM, Sochat V, Bauer MW (2017) Singularity: Scientific containers for mobility of compute. PLoS ONE 12(5): e0177459. https://doi.org/10.1371/journal.pone.0177459

Resources