How to use docker / singularity on the HPC cluster

Requirements

module load singularity/singularity

Create a singularity image

hpc_login_gen.sh <project_name>

Test a singularity image (run on your PC or hpc-login)

singularity run <project_name>.sif

Submit a singularity image (run on cluster nodes)

This is a simple sbatch script example:

#!/bin/bash

#SBATCH -n 8 # Request 8 cores

module load singularity/singularity
singularity run <project_name>.sif

Submit the sbatch script:

sbatch my_script

Singularity with intel18

Create image

hpc_login_gen.sh <project_name>
singularity run --bind /opt/intel/compilers_and_libraries_2018.1.163:/opt/intel/compilers_and_libraries_2018.1.163 <project_name>.sif

Singularity with GPU

Create image

hpc_login_gen.sh <project_name>
singularity run --nv <project_name>.sif

Singularity with MPI

Create image

hpc_login_gen.sh <project_name>
singularity run --bind /usr/local/openmpi/openmpi-3.1.3-i18:/usr/local/openmpi/openmpi-3.1.3-i18 --bind /opt/intel/compilers_and_libraries_2018.1.163:/opt/intel/compilers_and_libraries_2018.1.163 <project_name>.sif

Transform a docker image to singularity (without MPI)

From the docker hub

From a docker image available on docker hub, create your <project_name>.def file with:

Bootstrap: docker
From: <my_image>:<my_tag>

From a docker local image

docker image save -o my_image.tar image_name:version
Bootstrap: docker
From: hpc-singularity.di.unistra.fr:5000/<my_image>
hpc_login_docker.sh <project_name>

Singularity help pages

Singularity official documentation