This version (2024/10/24 10:28) is a draft.
Approvals: 0/1

Singularity

  • Article written by Markus Stöhr (VSC Team)

stevedores_ny_1912.jpg

(pictures from Wikipedia)

Containerization (historical, post 1955)

container_ship_loading-700px.jpg

(picture from Wikimedia, see also http:%%//%%www.worldshipping.org)

Singularity:

  • container runs in user namespace
  • no privilege escalation
  • can be used in a multi-user environment

  • image: stored in a single file
  • build images with ‘recipes’
  • work interactively within container
section
setup executed before post
post install commands
files executed after post
environmentadd variables for runtime
runscript commands when container is executed
labels metadata
test
apps

Filename: OpenMPI-3.0.0

BootStrap: docker
From: centos:7.4.1708

%setup
     cp openmpi-3.0.0.tar.bz2 \
        ${SINGULARITY_ROOTFS}/usr/local/src/openmpi-3.0.0.tar.bz2
%post
    yum install -y gcc gcc-c++ gcc-gfortran 
    yum install -y wget tar make bzip2 gzip perl rsync zip
    yum install -y infinipath-psm-devel infinipath-psm 
    yum install -y libibverbs-devel libibverbs

    cd /usr/local/src 
    tar -xjf openmpi-3.0.0.tar.bz2
    cd openmpi-3.0.0  

    ./configure --prefix=/usr/local --with-hwloc --with-psm --with-verbs
    make -j 16
    make install
    ldconfig

on your local system as root user:

#singularity must be present
module load singularity/2.4.2

singularity build OpenMPI-3.0.0.img OpenMPI-3.0.0

Filename: MPI-Hello

BootStrap: localimage
From: .../OpenMPI-3.0.0.img

%post
    yum install -y git
    mkdir /usr/local/src/git 
    cd /usr/local/src/git  

    git clone https://github.com/wesleykendall/mpitutorial 
    cd mpitutorial/tutorials/mpi-hello-world/code 
    make 
    cp mpi_hello_world /usr/local/bin 

%runscript
    /usr/local/bin/mpi_hello_world $@

singularity build MPI-Hello.img MPI-Hello
  • Copy image to VSC-3
  • Job script:
#!/bin/bash
#SBATCH -J singularity
#SBATCH -N 2


module purge
module load intel/18 openmpi/3.0.0 singularity/2.4.2

mpirun -np 32 ./MPI-Hello.img

scaling_vasp.eps.jpg

<html><br></html> <html><br></html> <html><br></html> <html><br></html> <html><br></html> <html><br></html> <html><br></html> http://singularity.lbl.gov

  • pandoc/singularity/01_introduction/singularity.txt
  • Last modified: 2024/10/24 10:28
  • by 127.0.0.1