All materials (c) 2020-2023 by CSC – IT Center for Science Ltd. This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 Unported License, http://creativecommons.org/licenses/by-sa/4.0/
$PATH
by default.apptainer exec [exec options...] <container> <command>
apptainer run [run options...] <container>
apptainer shell [shell options...] <container>
--bind (-B)
option/scratch/project_2001234
to the /data
directory inside the container: --bind /scratch/project_2001234:/data
/host/dir:/container/dir
--bind /scratch:/scratch
and --bind /scratch
do the same--bind /projapp,/scratch
and --bind /projappl --bind /scratch
do the same--bind /scratch/project/my_dataset.sqfs:/data:image-src=/
apptainer_wrapper
1/3apptainer_wrapper
takes care of the most common --bind
commands automatically
$TMPDIR
if set and directory exists$LOCAL_SCRATCH
if setapptainer exec --bind
apptainer_wrapper
2/3You need to set the $SING_IMAGE
environment variable to point to the correct Apptainer image file
apptainer_wrapper
3/4$SING_FLAGS
--bind
statements--nv
to use host CUDA--cleanev
if necessary--cleanenv
$APPTAINERENV_variablename
.
$TEST
in a container, set $APPTAINERENV_TEST
on the host~/.apptainer
.apptainer/cache
can fill up fast if you pull/build containers
Can be safely emptied
$APPTAINER_CACHEDIR
and $APPTAINER_TMPDIR
apptainer exec
apptainer run
can cause complications, i.e. variables not inherited as expected, etcapptainer_wrapper
, remember to bind all necessary directoriesReserve it in the batch job script:
--gres=gpu:v100:<number_of_gpus_per_node>
Also add option --nv
Depending on the container you may also need to set APPTAINERENV_LD_LIBRARY_PATH
Reserve it in the batch job script:
#SBATCH --gres=nvme:<local_storage_space_per_node>
$LOCAL_SCRATCH
and $TMPDIR
are set by the system if NVMe resources allocated for the job
apptainer_wrapper
, $LOCAL_SCRATCH
and $TMPDIR
are bound automatically--bind $LOCAL_SCRATCH:$TMPDIR
--bind $TMPDIR:/tmp
mksquashfs my_dataset my_dataset.sqfs
singularity exec --bind my_dataset.sqfs:/data:image-src=/ image.sif myprog
#!/bin/bash
#SBATCH --job-name=example
#SBATCH --account=project_12345
#SBATCH --partition=small
#SBATCH --time=02:00:00
#SBATCH --ntasks=1
#SBATCH --mem-per-cpu=4000
export SING_IMAGE=/scratch/project_12345/image.sif
export SING_FLAGS="--bind /scratch/project_12345/my_reference:/reference $SING_FLAGS"
apptainer_wrapper exec myprog -i input -o output
$PYTHONPATH
or $PERL5LIB
set on host, etc.
.bashrc
--cleanenv
prevents host environment variables from being inherited--cleanenv
export LC_ALL=C
Seems to happen mainly with Python
If you get X11 related error message, try unsetting $DISPLAY
unset DISPLAY
/tmp
$TMPDIR