Container 101 on Lawrencium

June 10, 2020

Wei Feinstein

Outline

Lawrencium Cluster Overview

Detailed informaton of Lawrencium

Accounts on Lawrencium

Three types of Project Accounts

https://sites.google.com/a/lbl.gov/hpc/getting-an-account

User accounts

https://sites.google.com/a/lbl.gov/hpc/getting-an-account

Softwre Module Farm

Module commands

https://sites.google.com/a/lbl.gov/high-performance-computing-services-group/getting-started/sl6-module-farm-guide

SLURM: Resource Manager & Job Scheduler

Jub Submission

sbatch --help
sbatch myjob.sh
srun -A ac_xxx -p lr5 -q lr_normal -t 1:0:0 --pty bash
salloc –A pc_xxx –p lr6 –q lr_debug –t 0:30:0

Job Monitoring

sinfo –r –p lr6
squeue –u $USER
sacct -X -o 'jobid,user,partition,nodelist,stat'
scancel jobID
sacctmgr show association user=wfeinstein -p
perceus-00|ac_test|wfeinstein|lr6|1||||||||||||lr_debug,lr_lowprio,lr_normal|||
perceus-00|ac_test|wfeinstein|lr5|1||||||||||||lr_debug,lr_lowprio,lr_normal|||
perceus-00|pc_test|wfeinstein|lr4|1||||||||||||lr_debug,lr_lowprio,lr_normal|||
perceus-00|lr_test|wfeinstein|lr3|1||||||||||||lr_debug,lr_lowprio,lr_normal,te
perceus-00|scs|wfeinstein|es1|1||||||||||||es_debug,es_lowprio,es_normal|||

https://sites.google.com/a/lbl.gov/high-performance-computing-services-group/scheduler/slurm-usage-instructions

Services (1)

Service (2): Jupyterhub

LRC Jupyterhub

Services (3): Cloud Computing

AWS & GCP Services

Type AWS GCP
Overall 7% 13%
Data Egress 15% 25%

Virtual Machine Services

More information of VM click here

Containerization

Applications

Container vs. Virtual Machine

Singularity Technology

Docker

Learn more docker

Singularity Workflow

Singularity Installation

OS platforms

- Linux
- Mac
- Window

Refer to instructions here for details

Test your installation:

$ singularity --version
  singularity version 3.2.1-1 
$ singularity run docker://godlovedc/lolcow
 ______________________________________
/ A tall, dark stranger will have more \
\ fun than you.                        /
 --------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Create Singularity Containers

Singularity pull directly from docker:// & shub://

singularity pull --help
$ singularity pull docker://ubuntu:18.04 
$ singularity pull docker://gcc:7.2.0
$ singularity pull hello-world.sif shub://singularityhub/hello-world

Run Singularity with shell, run, exec

singularity shell hello-world.sif
singularity run hello-world.sif
singularity exec hello-world.sif cat /etc/os-release

Singularity pull when Docker Containers Provided by Other External docker repositories

Steps to build singularity containers from NGC:

$ docker pull nvcr.io/hpc/pgi-compilers:ce
.....

$ docker images
REPOSITORY                     TAG              IMAGE ID            CREATED             SIZE
nvcr.io/hpc/pgi-compiler        ce            c13ce6cf7f66        6 months ago        9.9GB
openmpi3.1                    latest          08a5518bb344        9 months ago        14.3GB
registry                         2            f32a97de94e1        15 months ago       25.8MB
...

Steps to build singularity containers from NGC:

$ singularity build pgi.sif docker-daemon://nvcr.io/hpc/pgi-compilers:ce
$ ls
Dokerfile  hello-world.sif  pgi.sif  saxpy.c  Singularity
$ singularity exec pgi.sif pgcc -o saxpy -acc -Minfo saxpy.c
saxpy:
      9, Loop is parallelizable
         Generating Tesla code
          9, #pragma acc loop gang, vector(128) /* blockIdx.x threadIdx.x */
      9, FMA (fused multiply-add) instruction(s) generated
...
$ singularity exec pgi.sif ./saxpy
y[0] = 2.000000

Another example of using docker containers from AWS

Singularity build

singularity build --help
sudo singularity --debug build mycontainer.sif Singularity 

Definition File/Recipe

Bootstrap: docker
#library, docker, shub, localimage, yum, debootstrap, arch, busybox, zypper 
From: ubuntu

# used singularity run-help 
%help
Hello. I'm in the container.

# executed on host after the base OS is installed.
%setup
    touch ${SINGULARITY_ROOTFS}/tacos.txt
    echo "I love avocado" >> avocados.txt

# copy files from your host system into the container 
%files
    avocados.txt /opt    

%environment
  export NAME=avocado

# executed within the container after the base OS is installed at build time
#install new software and libraries, config files,  directories, etc
%post
    echo 'export Avocado=TRUE' >> $SINGULARITY_ENVIRONMENT

# executed when the container image is run:  singularity run
%runscript 
    echo "Hello! Arguments received: $* \n"
    exec echo "$@"  

More information of singularity recipes

Singularity Build Rewritable Sandbox

sudo singularity build --sandbox gccbox docker://gcc:7.2.0
sudo singularity build --sandbox test-box Singularity 
sudo singularity shell --writable test-box
sudo singularity build test-box.sif test-box

Inspect Containers

singularity inspect [options] image_name
    --lablels
    --runscript
    --deffile
    --environment
e.g. singularity inspect --deffile mycontainer.sif

Singularity Python (spython)

spython recipe Dockerfile > dock2sif.def

Run Singularity Containers on Lawrencium

scp xxx.sif $USER@lrc-xfer.lbl.gov:/your/path/on/cluster 

Job Submission Example

#!/bin/bash -l
#SBATCH --job-name=container-test        
#SBATCH --partition=lr5          
#SBATCH --account=ac_xxx         
#SBATCH --qos=lr_normal         
#SBATCH --nodes=1           
#SBATCH --time=1-2:0:0          

cd $SLURM_SUBMIT_DIR
singularity exec mycontainer.sif cat /etc/os-release

Container Bind Path

-B /host/path/:/container/path

singularity run --nv -B /global/home/users/$USER:/tmp pytorch_19_12_py3.sif ls /tmp

Run GPU and MPI Containers

singularity exec --nv pytorch_19_12_py3.sif python -c "import torch; print(torch.__version__)"
1.4.0a0+a5b4d78

Run MPI Containers

Exercise

Getting help

Please fill out Training Survey to get your comments and help us improve.