Containers on the HPC Cluster
The Resnick High Performance Computing Center supports Apptainer (formerly Singularity) for containerized computing.
Why Containers?
Reproducible software environments
Complex dependency management
Use Docker images from Docker Hub
No root privileges required
Loading Apptainer
module load apptainer/1.1.9-gcc-11.3.1-mbji4yi
Basic Operations
Pull an Image
From Docker Hub:
apptainer pull docker://sylabsio/lolcow:latest
This converts OCI blobs to SIF (Singularity Image Format).
Run a Container
apptainer run lolcow_latest.sif
Execute Commands
apptainer exec lolcow_latest.sif cat /etc/os-release
Interactive Shell
apptainer shell lolcow_latest.sif
Binding Directories
Mount local directories into the container with --bind:
apptainer exec --bind /resnick:/resnick myimage.sif ./myprogram
Multiple binds (e.g., group storage plus your home directory):
apptainer exec --bind /resnick:/resnick,$HOME:$HOME myimage.sif ./myprogram
GPU Support
For GPU-enabled containers, add --nv:
apptainer exec --nv tensorflow.sif python train.py
Example SLURM Script
#!/bin/bash
#SBATCH --job-name=container_job
#SBATCH --partition=gpu
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --gres=gpu:p100:1
#SBATCH --time=1:00:00
module load apptainer/1.1.9-gcc-11.3.1-mbji4yi
apptainer exec --nv --bind /resnick:/resnick \
mycontainer.sif python train.py
Building Containers
Note
Apptainer’s remote build option is no longer supported since Apptainer was rolled into the Linux Foundation. Build containers locally and transfer the .sif file to the cluster.
Popular Container Registries
NVIDIA NGC - GPU-optimized containers
BioContainers - Bioinformatics tools