Singularity on the SCC
The standard singularity software is installed in /opt/singularity
.
The main command for using singularity is /opt/singularity/bin/singularity
and can be called directly with singularity
. Please refer to Singularity documentation at http://singularity.lbl.gov/ for general use information.
Wrapper for Singularity
In order to facilitate integration with the SCC, we provide a command wrapper scc-singularity
:
[rcs@scc1 ~] scc-singularity run my_container.sif
The wrapper is available on the PATH for general use and provides the following features:
- Automatically binds:
- user’s home directory
- user’s project spaces
- the node(s)
/scratch
/usr/local
/share
- Preserves and passes into the container SCC environment variables:
DISPLAY
NSLOTS
TMPDIR
USER
- Will detect if using GPU(s) and pass
CUDA_VISIBLE_DEVICES
into the container.
If the container has code installed into its own /usr/local
directory, then pass the --nolocal
flag to scc-singularity:
[rcs@scc1 ~] scc-singularity --nolocal run my_container.sif
The --scc-preview
and --scc-debug
commands can be used to print out the command executed by the scc-singularity
wrapper:
[rcs@scc1 ~] scc-singularity --scc-preview run my_container.sif
/usr/bin/singularity run -e -B /share -B /usr1 -B /usr2 -B /usr3 -B /usr4 -B /var/spool/sge -B /project -B /projectnb -B /projectnb2 -B /scratch -B /net -B /ad -B /usr/local -B /var/lib/dbus/machine-id my_container.sif
preview mode - command not executed
Interactive Usage
Singularity can be used to run a shell interactively inside a container. This is accomplished using the shell
subcommand. To try these commands, first get a copy of a container running the Debian 11 operating system from the Sylabs container library. This will create a container file called debian_11.sif
:
[rcs@scc1 ~] singularity pull library://debian:11
Now try to run the container:
[rcs@scc1 ~] singularity shell debian_11.sif
Singularity> grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
It is important to note that standard “shell” mode will not provide full environment settings required to interact with modules and other SCC provided features.
The scc-singularity
command has an additional subcommand myshell
which invokes your default login shell with your complete login environment.
[rcs@scc1 ~] scc-singularity myshell debian_11.sif
Batch Usage
There are two main subcommands for running Singularity in batch: exec
and run
.
- Use the
exec
subcommand to execute the specified command within the container.#!/bin/bash -l #$ -P proj_name #$ -N singularity_exec #$ -j y # Run the container and execute a command within it. scc-singularity exec debian_11.sif grep PRETTY_NAME /etc/os-release
- Use the
run
subcommand to run the command that the container is pre-configured to run.#!/bin/bash -l #$ -P proj_name #$ -N singularity_run #$ -j y # Run the container and run its preconfigured command. scc-singularity run debian_11.sif