Programm from Container
Running software from a docker container using slurm on Curta
Getting, converting and starting software from a Docker container is illustrated using the example of the molecular dynamics package Gromacs[1]. There is a local installation of gromacs, cf. module av gromacs
.
Singularity [2] is used for the running of the container.
[2] https://sylabs.io/guides/2.6/user-guide/singularity_and_docker.html
Preparation:
Create a directory in /scratch, /scratch/$USER/gromacs
. Change the working directory to the new directory
cd /scratch/$USER/gromacs
.
Get the example input for a molecular dynamics simulation with gromacs
wget https://www.mpibpc.mpg.de/15101317/benchMEM.zip
.
Unpack the content of the file.
unzip benchMEM.zip
.
If you care to understand what this calculation is about, please check the description at https://www.mpibpc.mpg.de/grubmueller/bench
Get and prepare a container from Docker hub for local execution using the script get_container.sh
This might take some resources, so it is scheduled with slurm.
get_container.sh
#!/bin/bash
#SBATCH --job-name=singularity_build
#SBATCH --ntasks=1
#SBATCH --mem=2gb # depends on the size of the container
#SBATCH --time=00:10:00 # see above
#SBATCH --qos=standard
module load singularity # Environment for running containers
#Create a place for your containers. If you don't change the content of the container, use /scratch.
mkdir -p /scratch/$USER/images
cd /scratch/$USER/images
# Get and prepare the container
# Infos for this gromacs container https://hub.docker.com/r/gromacs/gromacs
singularity pull docker://gromacs/gromacs:2020.2
#Check the result
ls -l
Check Container
Submit script
# sbatch get_container.sh
Before the next step, check if a container with the name gromacs_2020.2.sif
was created in /scratch/$USER/images
. Check the ouput of job in slurm-XXXXXX.out
.
The path containing the programm you are going to use and the exact name as well as libraries to be included which are local installation should be taken from the documentation of the container.
Gromacs can be compiled to use GPU acceleration by including CUDA libraries. In this example the local CUDA installation will be included and the library path is extended by module load CUDAcore/11.1.1
.
The switch "-nv" to the call of singularity will enable this for Gromacs in this example.
To check if the path is correct and a runable binary is found, gromacs is called with the --version option.
Check if the container works and contains the gromacs version of interest
#!/bin/bash
#SBATCH --job-name=singularity_gmx_version
#SBATCH --ntasks=1
#SBATCH --mem=1gb # depends on the size of the container
#SBATCH --time=00:00:30 # see above
#SBATCH --qos=standard
#SBATCH --partition=gpu
#SBATCH --gres=gpu:1
#module load mksquashfs
module load singularity CUDAcore/11.1.1
mkdir -p /scratch/$USER/gromacs
cd /scratch/$USER/gromacs
# singularity arguments
# run
# --nv for Nvidia Cuda driver access
# --bind map filesystem into the container
singularity run --nv --bind /scratch/$USER/gromacs:/myscratch /scratch/$USER/images/gromacs_2020.2.sif /gromacs/bin/gmx --version
Run gromacs from container
The job output should contain the gromacs version:
grep "GROMACS version" slurm-XXXXXXX.out GROMACS version: 2020.2
Executing the programm with data from the local file system
For easy reproduction, the creation of the working directory and getting the file is included. Uncomment these lines if you skipped this step (s. above) before. To check the functionalityof of the demo case only two timesteps will be run.
#!/bin/bash
#SBATCH --job-name=singularity_gmx_version
#SBATCH --ntasks=1
#SBATCH --mem=500mb # depends on the size of the container
#SBATCH --time=00:00:10 # see above
#SBATCH --qos=standard
#SBATCH --partition=gpu
#SBATCH --gres=gpu:1
module load singularity CUDAcore/11.1.1
mkdir -p /scratch/$USER/gromacs
cd /scratch/$USER/gromacs
#wget https://www.mpibpc.mpg.de/15101317/benchMEM.zip
#unzip benchMEM.zip
ls -l
# run gromacs in a singularity container
# singularity arguments
# run
# --nv for Nvidia Cuda driver access
# --bind map filesystem into the container
singularity run --nv --bind /scratch/$USER/gromacs:/myscratch \
/scratch/$USER/images/gromacs_2020.2.sif \
/gromacs/bin/gmx \
mdrun -s /myscratch/benchMEM.tpr -nsteps 2
# Files from outside of the container, normal file system
ls -l /scratch/$USER/gromacs