Apptainer#
Apptainer is a platform that allows running containers in HPC environments. Originally, Singularity was the tool used for this purpose, but its development was forked into Apptainer, which is now the recommended standard in the HPC community.
Warning
Singularity is now deprecated and will be removed in the future, so we recommend users migrate their workflows to Apptainer.
Apptainer supports running containers with MPI and GPU support. Additionally, it can be integrated into Slurm scripts without issues.
Using Apptainer at TeideHPC#
Info
We currently have version 1.3.6 of Apptainer available at TeideHPC.
We can load the software using modules:
Docker Containers#
Apptainer uses its own container format .sif
, so Docker containers must be converted. However, this is done automatically without user intervention.
Downloading Containers from DockerHub#
Info
Container downloads should always be performed from the login nodes, which have Internet access, and not from the compute nodes.
Example of downloading an image from DockerHub for use in the cluster:
This will generate an image file in the current directory:
To run the container:
Warning
Running software on login nodes is not allowed. Use salloc
to request a compute node and execute it there.
If we need to build a container from Docker, we can use:
Running a Container#
To run a container:
We can also execute a specific command inside the container:
To get an interactive shell inside the container:
Running a Container in Slurm#
We can run Apptainer in Slurm like any other software:
#!/bin/bash -l
#SBATCH -J apptainer_job
#SBATCH -p batch
#SBATCH --nodes=1
#SBATCH -o out.log
#SBATCH -e err.log
module load Apptainer/1.3.6
apptainer run $HOME/hello-world_latest.sif
Slurm treats Apptainer like any other software, applying the same resource constraints, such as CPU, memory, and time limits.
Using MPI#
Tip
MPI support depends on the software being executed, not Apptainer. Therefore, we ask users to carefully read their software documentation before running anything.
If the software inside the container supports MPI, we can run it with srun
:
#!/bin/bash -l
#SBATCH -J apptainer_mpi
#SBATCH -p batch
#SBATCH --nodes=2
#SBATCH -o out.log
#SBATCH -e err.log
module purge
module load Apptainer/1.3.6
module load GCC/12.2.0 OpenMPI/4.1.4
srun apptainer run $HOME/hello-world_latest.sif
Using GPU#
Tip
GPU support depends on the software being executed, not Apptainer. Therefore, we ask users to carefully read their software documentation before running anything.
To use a GPU, we need to add the --nv (enable Nvidia support)
parameter to Apptainer:
Example in Slurm:
#!/bin/bash -l
#SBATCH -J apptainer_gpu
#SBATCH -p gpu
#SBATCH --cpus-per-task=4
#SBATCH --gpus=a100:1
#SBATCH -o out.log
#SBATCH -e err.log
module purge
module load Apptainer/1.3.6
apptainer run --nv $HOME/hello-world_latest.sif
Other Options#
We can bind directories from the host inside the container using -B
: