Using SBGrid Programs on HPC Clusters with Apptainer
Overview
This document explains how members of the SBGrid Consortium can utilize Apptainer (formerly known as Singularity) to run the SBGrid software collection on High-Performance Computing (HPC) clusters.
Problem
Software titles in the SBGrid collection assume executables are available at /programs/ (either as a direct path, or by symbolic link). At HPC sites, it is sometimes not feasible to create this entry at the root filesystem for all compute nodes.
Approach
Use the SBGrid Installation Manager to install titles without the link, and use Apptainer's bind-mount feature to make it accessible to these titles when using them.
Prerequisites
- Apptainer available at your cluster
- Sufficient available space for the SBGrid titles being installed, and a minimal apptainer image
- Installation manager credentials
Notes on this documentation
Things that may need to be changed:
- name of apptainer definition file, this documentation uses "sbgrid-a9-minimal.def"
- name of apptainer container, this documentation uses "sbgrid-a9-minimal.sif"
- any "module load" statements necessary for the HPC cluster for apptainer
- SLURM partition names, and other SLURM parameters for GPU access at your cluster.
Things that will need to be changed:
- path to the SBGrid installation, this documentation uses "/home/your_username/software/sbgrid"
- SBGrid installation manager credentials, this documentation uses "your_site", "your_username", "your_key"
- SBGrid titles and versions you'd like to install; this documentation uses "relion@5.0.1_cu12.8" (for an example GPU accelerated title) and "phenix@1.21-5207" (for an example CPU-only title)
Setup and Configuration
Install SBGrid without /programs link
./sbgrid-cli activate your_site your_username your_key --target /home/your_username/software/sbgrid --no-link
Install SBGrid titles
This can be done outside the container if desired.
Build minimal container
Copy and paste the following into a text file called sbgrid-a9-minimal.def or download a copy :
BootStrap: docker
From: almalinux:9
%post
yum install -y ncurses freetype fontconfig zlib tcsh rsync
yum install -y mesa-libGL which openssl libxcrypt libxcrypt-compat nss
yum install -y libxcb xcb-util xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm xcb-util-cursor libnsl
yum install -y glibc-langpack-en
%environment
export LANG=en_US.UTF-8
export LC_ALL=C
Build the minimal container:
Usage
Interactive Usage
-
Request interactive SLURM session
For an interactive GPU session (if your cluster supports this):
-
Within interactive session, once it has started
For GPU support:
-
Within the container
The output of the
sbinfocommand should have "Base path:/programs"Your
~/.bashrc(or tcsh equivalent) is typically used byapptainer shellandapptainer exec, so the environment can be automatically initialized.
Batch Usage
-
Write or Update your SLURM script
#!/usr/bin/env bash #SBATCH --job-name=ExampleBatchJob #SBATCH --output=ExampleJob-%j.out #SBATCH --error=ExampleJob-%j.err #SBATCH --partition=CpuPartition #SBATCH --nodes=1 #SBATCH --ntasks=5 #SBATCH --cpus-per-task=4 # initialize SBGrid environment source /programs/sbgrid.shrc # data processing commands sbinfo sbwhich phenix phenix.version -
Submit job