Singularity
Singularity is an open-source software to create, develop and run containers. As opposed to the more popular Docker it does not need root or admin rights and can therefore be used on the managed Linux workstations of D-PHYS and the HPC clusters of ETH. It is compatible with docker images and also supports Nvidia and CUDA inside the containers.
- Container images are stored in
~/.singularity/
. Please use a symlink to a local disk (or adapt the corresponding env variable) to avoid filling your home folder quota. - The current folder as well as your home and local
/tmp
folders will be mounted inside the container to provide access to your files. - Some features require additional configuration. Please get in touch with us if you need to build containers yourself.
Sample usage
The following one-liner downloads a docker image with GPU-enabled Tensorflow for Python3 and executes your code with it. Note the --nv
option to enable Nvidia support within the container.
singularity exec --nv docker://tensorflow/tensorflow:latest-gpu-py3 python <yourcode.py>
Commands
Help
singularity help # show usage overview of all commands
singularity help <command> # show detailed usage of given command
Pull
singularity pull docker://<image> # download and combine layered docker image into .sif
Cache
singularity cache list # list downloaded image files and how much disk space they use
singularity cache clean # remove cached image files to free disk space
Build
singularity build --fakeroot img.sif img.def # build a new singularity image from a definition file
singularity --debug build ... # show debug output while building container
The definition file, similar to a Dockerfile, contains the recipe to create the container:
BootStrap: docker
From: tensorflow/tensorflow:latest-gpu-py3
%post
apt-get -y install cowsay
%runscript
/usr/games/cowsay 'Moo'
Run
singularity run <image> # spawn a container and execute its runscript
Env variables and their default values
export SINGULARITY_TMPDIR='/tmp/' # directory to build the container
export SINGULARITY_CACHEDIR="$HOME/.singularity/cache" # directory to store the image cache