Skip to content

Singularity

For many reasons, it's not possible to use docker on our machine or in a compute grid.singularity is a docker alternative that allows users to use containers without special privileges.

Container creation

There's 2 way to create containers, the first one is to use an already existing docker, the second is to use a definition file.

Once the container is built, it is immutable so you can't write data into it or add software. However you'll have access to your account and you can add other diretories if needed.

Since these images require a lot of space, it is better to use a local disk to create them instead of creating them in your account. Also, once your container is build, you should clean the cache which is located in your account to free space

singularity cache clean

Docker

You can create a container from a docker one and run it as a normal user. For example, to build a pytorch container that is provided by pytorch, you can use this command.

singularity build pytorch.sif docker://pytorch/pytorch

Definition file

To build a more custom image, you'll need to have a personal computer with singularity installed since this needs root privileges which you can't have on our computers.

To build a container this way, you can use this command:

singularity build ecole.sif ecole.def

Here's an example of a definition file to install SCIP. You have to download the software so it can be copied inside the container for installation. In this example, we're using an older version of ubuntu as well as an older version of SCIP.

Bootstrap: docker
From: ubuntu:bionic

%files
    SCIPOptSuite-7.0.3-Linux-ubuntu.sh /root

%post
    echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

    apt-get -y update
    apt-get -y upgrade
    apt-get -y install gcc g++ gfortran liblapack3 libtbb2 libcliquer1 libopenblas-dev libgsl23
    bash /root/SCIPOptSuite-7.0.3-Linux-ubuntu.sh --skip-license
    rm /root/SCIPOptSuite-7.0.3-Linux-ubuntu.sh

%environment
    export LC_ALL=C

Using the container

Once the container is built, you can enter it with this command

    singularity shell pytorch.sif

You'll then have access to the tools installed inside it.

If you're on a GPU machine and you want to access it from inside the container, you'll need to use the --nv option.