-
Notifications
You must be signed in to change notification settings - Fork 161
Singularity
Jack Betteridge edited this page Jul 18, 2023
·
9 revisions
Process for running Firedrake scripts on ARCHER2 using a singularity container, rather than installing Firedrake
A two step procedure is required for performing the image conversion. This example uses the firedrake-vanilla
container, but firedrake
, firedrake-notebooks
and firedrake-complex
should also work correctly.
-
Build the image in a sandbox from the Dockerhub
singularity build --sandbox ./firedrake-vanilla docker://firedrakeproject/firedrake-vanilla
-
Convert the sandboxed image to a Singularity container
singularity build firedrake-vanilla.sif ./firedrake-vanilla
Example jobscript for running on ARCHER2:
#!/bin/bash
#SBATCH -p standard
#SBATCH -A account
#SBATCH -J singularity
#SBATCH --nodes=1
#SBATCH --cpus-per-task=1
#SBATCH --qos=standard
#SBATCH -t 0:10:00
myScript="HPC_demo.py"
module purge
module load load-epcc-module
module load PrgEnv-gnu/8.3.3
module swap cray-mpich cray-mpich-abi/8.1.23
module swap cray-libsci cray-libsci/22.12.1.1
module load xpmem
cat <<EOF >.gitconfig
[safe]
directory = *
EOF
export SINGULARITYENV_LD_LIBRARY_PATH="/opt/cray/pe/mpich/8.1.23/ofi/gnu/9.1/lib-abi-mpich:/opt/cray/pe/mpich/8.1.23/gtl/lib:/opt/cray/libfabric/1.12.1.2.2.0.0/lib64:/opt/cray/pe/gcc-libs:/opt/cray/pe/lib64:/opt/cray/xpmem/default/lib64:/usr/lib64/libibverbs:/usr/lib64"
export SINGULARITY_BIND="/opt/cray,/var/spool,/opt/cray/pe/mpich/8.1.23/ofi/gnu/9.1/lib-abi-mpich:/opt/cray/pe/mpich/8.1.23/gtl/lib,/etc/host.conf,/etc/libibverbs.d/mlx5.driver,/etc/libnl/classid,/etc/resolv.conf,/opt/cray/libfabric/1.12.1.2.2.0.0/lib64/libfabric.so.1,/opt/cray/pe/gcc-libs/libatomic.so.1,/opt/cray/pe/gcc-libs/libgcc_s.so.1,/opt/cray/pe/gcc-libs/libgfortran.so.5,/opt/cray/pe/gcc-libs/libquadmath.so.0,opt/cray/pe/lib64/libpals.so.0,/opt/cray/pe/lib64/libpmi2.so.0,/opt/cray/pe/lib64/libpmi.so.0,/opt/cray/xpmem/default/lib64/libxpmem.so.0,/run/munge/munge.socket.2,/usr/lib64/libibverbs/libmlx5-rdmav34.so,/usr/lib64/libibverbs.so.1,/usr/lib64/libkeyutils.so.1,/usr/lib64/liblnetconfig.so.4,/usr/lib64/liblustreapi.so,/usr/lib64/libmunge.so.2,/usr/lib64/libnl-3.so.200,/usr/lib64/libnl-genl-3.so.200,/usr/lib64/libnl-route-3.so.200,/usr/lib64/librdmacm.so.1,/usr/lib64/libyaml-0.so.2"
export SINGULARITYENV_OMP_NUM_THREADS=1
export SINGULARITYENV_PYOP2_CACHE_DIR=/tmp/$USER/pyop2
export SINGULARITYENV_PYOP2_CC=/home/firedrake/firedrake/bin/mpicc
export SINGULARITYENV_PYOP2_CXX=/home/firedrake/firedrake/bin/mpicxx
export SINGULARITYENV_FIREDRAKE_TSFC_KERNEL_CACHE_DIR=/tmp/$USER/tsfc
srun --ntasks-per-node 128 \
singularity run --bind $PWD:/home/firedrake/work --home $PWD firedrake-vanilla.sif \
/home/firedrake/firedrake/bin/python \
/home/firedrake/work/${myScript}
If you save this jobscript as firedrake_jobscript.slm
it can be submitted to the queue by executing
sbatch firedrake_jobscript.slm
on the login node.
Key points to note:
- We assume the script referenced bt the bash variable
myScript
is in the current directory and that directory is somewhere in the ARCHER2/work
filesystem not the/home
filesystem. - We use
cray-mpich-abi
in place ofcray-mpich
. - A
.gitconfig
file is created marking all directories as safe for git. This is necessary since the Docker container runs as thefiredrake
user, but Singularity runs as the current user. Without it each rank spews many errors, sometimes crashing the interconnect. Since the$PWD
is mounted as home the Singularity container sees this file as$HOME/.gitconfig
. -
export SINGULARITYENV_LD_LIBRARY_PATH
andexport SINGULARITY_BIND
are ARCHER2 specific and essential. - A
SINGULARITYENV_FOO
environment variable sets the environment variableFOO
instide the singularity container. -
PYOP2_CACHE_DIR
andFIREDRAKE_TSFC_KERNEL_CACHE_DIR
deafult to the$HOME
directory on the host and is automatically mounted inside the singularity container. This is an issue on ARCHER2, since$HOME
is not mounted on compute nodes. To ensure the location is writable these are set to directories in/tmp
. Any writable alternative location could be used (for instance$PWD
). -
PYOP2_CC
andPYOP2_CXX
are set to ensure the container compiler are used. - The argument
--bind $PWD:/home/firedrake/work
is necessary to mount the current directory somewhere sensible within the container so that the script on the host filesystem can be executed in the container. - The argument
--home $PWD
ensures that any files written to$HOME
in the container are written to the current directory. USeful when output files are written to a relative path rather than absolute, since the default user directory inside the container is normally$HOME
.
Building locally
Tips
- Running Firedrake tests with different subpackage branches
- Modifying and Rebuilding PETSc and petsc4py
- Vectorisation
- Debugging C kernels with
lldb
on MacOS - Parallel MPI Debugging with
tmux-mpi
,pdb
andgdb
- Parallel MPI Debugging with VSCode and
debugpy
- Modifying generated code
- Kernel profiling with LIKWID
- breakpoint() builtin not working
- Debugging pytest with multiple processing
Developers Notes
- Upcoming meeting 2024-08-21
- 2024-08-07
- 2024-07-24
- 2024-07-17
- 2024-07-10
- 2024-06-26
- 2024-06-19
- 2024-06-05
- 2024-05-29
- 2024-05-15
- 2024-05-08
- 2024-05-01
- 2024-04-28
- 2024-04-17
- 2024-04-10
- 2024-04-03
- 2024-03-27
- 2024-03-20
- 2024-03-06
- 2024-02-28
- 2024-02-28
- 2024-02-21
- 2024-02-14
- 2024-02-07
- 2024-01-31
- 2024-01-24
- 2024-01-17
- 2024-01-10
- 2023-12-13
- 2023-12-06
- 2023-11-29
- 2023-11-22
- 2023-11-15
- 2023-11-08
- 2023-11-01
- 2023-10-25
- 2023-10-18
- 2023-10-11
- 2023-10-04
- 2023-09-27
- 2023-09-20
- 2023-09-06
- 2023-08-30
- 2023-08-23
- 2023-07-12
- 2023-07-05
- 2023-06-21
- 2023-06-14
- 2023-06-07
- 2023-05-17
- 2023-05-10
- 2023-03-08
- 2023-02-22
- 2023-02-15
- 2023-02-08
- 2023-01-18
- 2023-01-11
- 2023-12-14
- 2022-12-07
- 2022-11-23
- 2022-11-16
- 2022-11-09
- 2022-11-02
- 2022-10-26
- 2022-10-12
- 2022-10-05
- 2022-09-28
- 2022-09-21
- 2022-09-14
- 2022-09-07
- 2022-08-25
- 2022-08-11
- 2022-08-04
- 2022-07-28
- 2022-07-21
- 2022-07-07
- 2022-06-30
- 2022-06-23
- 2022-06-16
- 2022-05-26
- 2022-05-19
- 2022-05-12
- 2022-05-05
- 2022-04-21
- 2022-04-07
- 2022-03-17
- 2022-03-03
- 2022-02-24
- 2022-02-10
- 2022-02-03
- 2022-01-27
- 2022-01-20
- 2022-01-13
- 2021-12-15
- 2021-12-09
- 2021-11-25
- 2021-11-18
- 2021-11-11
- 2021-11-04
- 2021-10-28
- 2021-10-21
- 2021-10-14
- 2021-10-07
- 2021-09-30
- 2021-09-23
- 2021-09-09
- 2021-09-02
- 2021-08-26
- 2021-08-18
- 2021-08-11
- 2021-08-04
- 2021-07-28
- 2021-07-21
- 2021-07-14
- 2021-07-07
- 2021-06-30
- 2021-06-23
- 2021-06-16
- 2021-06-09
- 2021-06-02
- 2021-05-19
- 2021-05-12
- 2021-05-05
- 2021-04-28
- 2021-04-21
- 2021-04-14
- 2021-04-07
- 2021-03-17
- 2021-03-10
- 2021-02-24
- 2021-02-17
- 2021-02-10
- 2021-02-03
- 2021-01-27
- 2021-01-20
- 2021-01-13
- 2021-01-06