Singularity is a containerization platform that allows users to run applications in isolated environments, ensuring reproducibility across different computing systems. By encapsulating your entire environment in a container, you can ensure that your research code runs the same way on different systems. Note: the singularity build command with definition files is not supported on SeaWulf due to privilege requirements.

Using Singularity

On SeaWulf and NVwulf's current nodes there is no module to load: Singularity (also called Apptainer) is already installed. Check that it is there with:

singularity --version
Tip: if your older job scripts have a module load singularity line, remove it. If the singularity command isn't found, contact HPC support.

Example usage

Pull container images from Docker Hub

singularity pull docker://ubuntu:20.04
singularity pull docker://python:3.9
singularity pull docker://tensorflow/tensorflow:latest-gpu

Pull a container image from the Singularity Library

singularity pull library://alpine:latest

Build a container locally (not supported on SeaWulf)

sudo singularity build my_container.sif my_definition.def

Transfer a container to SeaWulf

scp my_container.sif username@milan.seawulf.stonybrook.edu:~/path/to/directory/

Run or execute commands in a container

singularity run my_container.sif
singularity exec my_container.sif my_custom_command
singularity exec my_container.sif python3 my_script.py

Can I use Docker?

Not directly. Docker needs administrator (root) rights, which aren't available on a shared cluster. Singularity runs Docker images without them. Apptainer is the newer name for the same project, and its commands work the same way.

  1. Check that it is available: singularity --version (no module needed)
  2. Turn a Docker image into a Singularity image file (.sif):

    singularity pull docker://python:3.11
  3. Run it in your job script:

    singularity exec python_3.11.sif python3 my_script.py
  4. For GPU jobs, add --nv so the container can use the node's NVIDIA GPUs:

    singularity exec --nv my_image.sif python3 train.py

Images are large, so pull them into scratch or project space rather than your home folder. Images that need root to build can't be built on the clusters: build them on your own computer and copy the .sif file over.

Availability

Singularity is available on: SeaWulf, NVwulf, ClinWulf.