Using Singularity on Seawulf

To read more about Singularity : https://sylabs.io/guides/3.0/user-guide/

To read more about Docker : https://www.docker.com/why-docker

Audience: Faculty, Postdocs, Researchers, Staff and Students

This KB Article References: High Performance Computing
This Information is Intended for: Faculty, Postdocs, Researchers, Staff, Students
Last Updated: June 11, 2020

'Singularity' is a containerization tool that facilitates virtualization of applications for HPC environments. This Knowledge Base (KB) article will help you run your own Singularity containers on Seawulf. If you are unfamiliar with using Singularity in an HPC environement, please read on.  Links to resources for further learning are provided at the end.


To begin using Singularity on Seawulf, load the Anaconda 3 module at the $ prompt:

module load anaconda/3

Next, activate the singularity 3 conda environment:

source activate singularity3

You can download a Singularity Image from a pre-built external resource as follows :

singularity pull shub://<singularity_hub_path_for_image> 

or 

singularity pull library://<singularity_library_path_for_image>

To run a Singularity Image, use the run command as follows : 

singularity run <image_name>.sif

To use a Singularity Image on a GPU node, to take advantage of the GPUs available use the --nv flag as follows :

singularity run --nv <image_name>.sif

This is recommended for running Containers with Deep Learning frameworks for Machine Learning/ Computer Vision/ NLP applications. Some popular examples are Tensorflow, PyTorch, Theano, Keras among others which can be accessed from the NVIDIA GPU Cloud repository. See https://ngc.nvidia.com 


To test that Singularity works you can try the following example :

First download the image,

singularity pull library://sylabsed/examples/lolcow

Next Run the image

singularity run lolcow_latest.sif

Please note that the following Singularity functions are not currently enabled on SeaWulf:

  • Using the "singularity build" command to build either a custom image or download an image from a public repository
  • Downloading a Docker image (using either "pull" or "build") from Docker Hub

If you need to download a Docker container or build a custom image, this should be down on your local machine, after which the image file may be transferred to SeaWulf.  Please see the instructions below for running Singularity locally.


To build your own custom Singularity container, you will need a local machine where you have administrator (root) privileges. We recommend using a Linux instance on VirtualBox (https://www.virtualbox.org) for your local machine, so that you can insulate your system from unwanted changes. We will refer to this as 'local machine' in the rest of this KB. 

To get an interactive shell as root user, type the following command at the $ prompt of your local machine.

sudo -i

Enter the root account password and if successful your $ prompt now becomes a # prompt to indicate you have root access.

Once you have root access to a local machine, install singularity on your local machine (https://singularity.lbl.gov/docs-installation).

For Ubuntu you can use the following command :

apt-get update && \
    sudo apt-get install \
    python \
    dh-autoreconf \
    build-essential \
    libarchive-dev

Choose a base image and build a writeable singularity container to ensure that changes made are persistent. (https://singularity.lbl.gov/docs-build-container)

singularity build --writable <image_name>.sif shub://<singularity_hub_path_for_image>

You can use version control software like git to clone an existing repository inside this container and install libraries you require. Please ensure you have set appropriate file permissions with the chmod command.

You can also use Singularity to pull Docker images from the repository and save it as a Singularity container as follows:

singularity pull --name <custom_name_for_image> docker://<image_path_on_docker_repository>

Once you have created the custom Singularity image, upload it to your Singularity repository for use.

Alternatively, copy it over to Seawulf using the sftp or scp utility.

scp <local_path>/<image_name>.sif <net_id>@login.seawulf.stonybrook.edu:<path_on_seawulf>/.

Recommended Reading :

For a quick guide to using Singularity : https://sylabs.io/guides/3.0/user-guide/quick_start.html


If you have issues / concerns / difficulties not addressed by the above article : Submit a ticket

Additional Information


There are no additional resources available for this article.

Getting Help


The Division of Information Technology provides support on all of our services. If you require assistance please submit a support ticket through the IT Service Management system.

Submit A Ticket

For More Information Contact


IACS Support System