Apptainer (formerly Singularity)
Description
Apptainer (formerly Singularity) is a free, cross-platform and open-source computer program that performs operating-system-level virtualization also known as containerization. One of the main uses of Apptainer is to bring containers and reproducibility to scientific computing and the high-performance computing (HPC) world.
The need for reproducibility requires the ability to use containers to move applications from system to system.
Using Apptainer containers, developers can work in reproducible environments of their choosing and design, and these complete environments can easily be copied and executed on other platforms.
To learn more about Apptainer itself please consult the Apptainer documentation.
Module
Load the modulefile
$ module load apptainer
This provides access to the apptainer
executable wich can be used to run containers.
Building images and running containers
On NHR you can build apptainer images directly on the login nodes.
For SCC you should use a compute node. For example by starting an interactive job:
$ srun --partition int --pty bash
$ module load apptainer
If you have written a container recipe foo.def
you can create a foo.sif
apptainer image in the following way:
$ module load apptainer
$ apptainer build foo.sif foo.def
Example Jobscripts
Here is an example job of running the local Apptainer image (.sif)
#!/bin/bash
#SBATCH -p medium40
#SBATCH -N 1
#SBATCH -t 60:00
module load apptainer
apptainer run --bind /local,/user,/projects,$HOME,$WORK,$TMPDIR,$PROJECT $HOME/foo.sif
#!/bin/bash
#SBATCH -p grete:shared
#SBATCH -N 1
#SBATCH -G 1
#SBATCH -t 60:00
module load cuda
module load apptainer
apptainer run --nv --bind /local,/user,/projects,$HOME,$WORK,$TMPDIR,$PROJECT $HOME/foo.sif
#!/bin/bash
#SBATCH -p medium
#SBATCH -N 1
#SBATCH -c 8
#SBATCH -t 1:00:00
module load apptainer
apptainer run --bind /local,/user,/projects,/home,/scratch $HOME/foo.sif