Changes between Version 4 and Version 5 of cypress/Singularity


Ignore:
Timestamp:
09/28/22 16:22:40 (2 years ago)
Author:
fuji
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • cypress/Singularity

    v4 v5  
    1414
    1515== Run Singularity Container on Cypress ==
     16For example, the container built [SingularityDockerhub this page]. In an interactive session by '''idev --partition=centos7''',
     17
     18{{{
     19[fuji@cypress01-013 SingularityTest]$ singularity exec ubuntu_14.04.sif cat /etc/os-release
     20NAME="Ubuntu"
     21VERSION="14.04.6 LTS, Trusty Tahr"
     22ID=ubuntu
     23ID_LIKE=debian
     24PRETTY_NAME="Ubuntu 14.04.6 LTS"
     25VERSION_ID="14.04"
     26HOME_URL="http://www.ubuntu.com/"
     27SUPPORT_URL="http://help.ubuntu.com/"
     28BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
     29}}}
     30
     31The user in the container is the same as in the host machine.
     32
     33{{{
     34[fuji@cypress01-013 SingularityTest]$ singularity exec ubuntu_14.04.sif whoami
     35fuji
     36}}}
     37
     38Singularity has a dedicated syntax to open an interactive shell prompt in a container:
     39
     40{{{
     41[fuji@cypress01-013 SingularityTest]$ singularity shell ubuntu_14.04.sif
     42Singularity> pwd
     43/home/fuji
     44Singularity> whoami
     45fuji
     46Singularity> cat /etc/os-release
     47NAME="Ubuntu"
     48VERSION="14.04.6 LTS, Trusty Tahr"
     49ID=ubuntu
     50ID_LIKE=debian
     51PRETTY_NAME="Ubuntu 14.04.6 LTS"
     52VERSION_ID="14.04"
     53HOME_URL="http://www.ubuntu.com/"
     54SUPPORT_URL="http://help.ubuntu.com/"
     55BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
     56Singularity> exit
     57exit
     58}}}
     59
     60=== Use host directories ===
     61The container filesystem is read-only, so if you want to write output files you must do it in a bind-mounted host directory.
     62'/home/userid' containing data and software are mounted by default.
     63
     64Following environ variable sets '/lustre/project/hpcstaff/fuji' as '/home/fuji' in the container.
     65{{{
     66export SINGULARITY_BINDPATH=/lustre/project/hpcstaff/fuji:/home/fuji
     67}}}
     68
     69
     70=== Run containters in a batch job ===
     71For example,
     72{{{
     73#!/bin/bash
     74#SBATCH --job-name=Singularity # Job Name
     75#SBATCH --partition=centos7    # Partition
     76#SBATCH --qos=normal           # Quality of Service
     77#SBATCH --time=0-00:10:00      # Wall clock time limit in Days-HH:MM:SS
     78#SBATCH --nodes=1              # Node count required for the job
     79#SBATCH --ntasks-per-node=1    # Number of tasks to be launched per Node
     80#SBATCH --cpus-per-task=1     # Number of threads per task (OMP threads)
     81
     82# Load Singularity module
     83module load singularity/3.9.0
     84
     85# Set $TMPDIR in containar to /tmp, keeping $TMPDIR in host (/local/tmp/...)
     86export SINGULARITYENV_TMPDIR=/tmp
     87
     88# Mount the lustre directory to home, $TMPDIR to /tmp
     89export SINGULARITY_BINDPATH=/lustre/project/hpcstaff/fuji:/home/fuji,$TMPDIR:/tmp
     90
     91# Run container
     92singularity exec ubuntu_14.04.sif ls
     93}}}
     94
    1695By default, the cache is stored in ~/.singularity; this location can be customized using the environment variable '''SINGULARITY_CACHEDIR'''.
    1796A subcommand, ''singularity cache'', can be used to manage the cache.