This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
research:containers [2019/02/27 14:20] itshililo [Using Singularity on Lengau Cluster] |
research:containers [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Singularity in a Nutshell ====== | + | ======Singularity in a Nutshell====== |
| - | Singularity is a container solution created for scientific and application workloads. The objective of this guide is to demonstrate how to use Singularity on the CHPC Lengau cluster. | + | Moved to [[howto:singularity|Singularity |
| - | + | ||
| - | The diagram below is a visual depiction of the Singularity work-flow process. This process can be categorised into two environments: | + | |
| - | * **Build** environment: | + | |
| - | * **Production** environment where users run containers. E.g (Lengau Cluster) | + | |
| - | + | ||
| - | For more details please read the user manual: | + | |
| - | + | ||
| - | {{ : | + | |
| - | + | ||
| - | Based on the image above, it is clear that the CHPC Lengau cluster will only provide a production (container execution) environment for the Singularity | + | |
| - | + | ||
| - | + | ||
| - | **NB:** Please note that the computes nodes on Lengau do not have access to the internet, which means that users will not be able to use the Singularity **pull** command. However, users can use the **scp.chpc.ac.ca** node to facilitate the transfer of images to and from the platform. | + | |
| - | + | ||
| - | ==== Using Singularity on Lengau Cluster ==== | + | |
| - | Using Singularity on Lengau can be summarised as a two-stage process: | + | |
| - | - **Transferring images to the Lengau cluster:** Users can use cp, SCP, rsync or FTP to copy their images on the cluster using the node://** scp.chpc.ac.za**// | + | |
| - | - **Container Execution** Users can only interact with the computes nodes through the scheduler using the **qsub** command. Users also need to load the chpc/ | + | |
| - | + | ||
| - | === Singularity: | + | |
| - | Below is an example of a recipe file for building a Centos-7 image and installing mpich-3.2.1 inside that image. This also includes an MPI example code for hello world programs. | + | |
| - | + | ||
| - | BootStrap: yum | + | |
| - | OSVersion: 7 | + | |
| - | MirrorURL: http:// | + | |
| - | Include: yum | + | |
| - | UpdateURL: http:// | + | |
| - | %runscript | + | |
| - | echo "This build MPICH-3.2.1 onto the base Centos7" | + | |
| - | %post | + | |
| - | echo -e " | + | |
| - | yum -y install vim wget bzip2 git unzip | + | |
| - | yum -y groupinstall " | + | |
| - | yum -y groupinstall " | + | |
| - | yum -y update | + | |
| - | echo -e " | + | |
| - | pushd /tmp | + | |
| - | if [ ! -f / | + | |
| - | wget http:// | + | |
| - | fi | + | |
| - | tar -xf mpich-3.2.1.tar.gz | + | |
| - | cd mpich-3.2.1 | + | |
| - | ./configure --prefix=/ | + | |
| - | make -j 4 | + | |
| - | make install | + | |
| - | mpicc examples/ | + | |
| - | popd | + | |
| - | rm -rf / | + | |
| - | echo -e " | + | |
| - | cd /tmp | + | |
| - | if [ ! -f / | + | |
| - | wget https:// | + | |
| - | fi | + | |
| - | unzip gh-pages.zip | + | |
| - | cd mpitutorial-gh-pages/ | + | |
| - | make clean | + | |
| - | make | + | |
| - | cp mpi_hello_world / | + | |
| - | %runscript | + | |
| - | # used with singularity run | + | |
| - | echo " | + | |
| - | exec hellow | + | |
| - | # Alternative mpi singularity run | + | |
| - | echo " | + | |
| - | exec mpi_hello_world | + | |
| - | + | ||
| - | Using the definition file above we can build a Singularity image on a system with singularity install and we have sudo privileges (i.e personal work station or VM). Use the command below to build the image: | + | |
| - | sudo singularity build $image_name $definition_file | + | |
| - | where **$image_name** is the name of the image your building and **$definition_file** with the filename for code provided above. | + | |
| - | + | ||
| - | Once we've built our image we can then transfer it to the Lengau cluster. | + | |
| - | rsync -azP $image_name $username@lengau.chpc.ac.za: | + | |
| - | where **$DIR_PATH** is the location you want to store your image. | + | |
| - | + | ||
| - | === Run Image on Lengau === | + | |
| - | Login to the cluster | + | |
| - | ssh $user@lengau.chpc.ca.za | + | |
| - | Submit your job using the qsub command and the resources you need | + | |
| - | qsub -I -P $PROJECT -q $Queue_name -l select=2: | + | |
| - | where $PROJECT is the project name to draw you alllocation and $QUEUE_NAME is the name of the Queue you want to run. | + | |
| - | + | ||
| - | Then load the Singularity and MPI module avail on the cluster | + | |
| - | module load chpc/ | + | |
| - | + | ||
| - | Then exec the program from the container | + | |
| - | + | ||
| - | $ mpirun -np 24 singularity exec mpich-3.2.1.simg-v2 hellow | + | |
| - | Hello world from process 20 of 24 | + | |
| - | Hello world from process 4 of 24 | + | |
| - | Hello world from process 5 of 24 | + | |
| - | Hello world from process 7 of 24 | + | |
| - | Hello world from process 12 of 24 | + | |
| - | Hello world from process 14 of 24 | + | |
| - | Hello world from process 6 of 24 | + | |
| - | Hello world from process 15 of 24 | + | |
| - | Hello world from process 22 of 24 | + | |
| - | Hello world from process 23 of 24 | + | |
| - | Hello world from process 13 of 24 | + | |
| - | Hello world from process 9 of 24 | + | |
| - | Hello world from process 11 of 24 | + | |
| - | Hello world from process 21 of 24 | + | |
| - | Hello world from process 16 of 24 | + | |
| - | Hello world from process 8 of 24 | + | |
| - | Hello world from process 0 of 24 | + | |
| - | Hello world from process 3 of 24 | + | |
| - | Hello world from process 18 of 24 | + | |
| - | Hello world from process 17 of 24 | + | |
| - | Hello world from process 10 of 24 | + | |
| - | Hello world from process 1 of 24 | + | |
| - | Hello world from process 19 of 24 | + | |
| - | Hello world from process 2 of 24 | + | |
| - | + | ||
| - | Alternative MPI code, with ranks and hostname | + | |
| - | + | ||
| - | $ mpirun -np 24 singularity exec mpich-3.2.1.simg-v2 mpi_hello_world | + | |
| - | Hello world from processor cnode0241, rank 4 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 15 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 5 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 6 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 20 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 21 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 22 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 13 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 7 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 14 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 12 out of 24 processors | + | |
| - | Hello world from processor cnode0241, rank 23 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 9 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 19 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 8 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 0 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 16 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 3 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 11 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 18 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 2 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 10 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 1 out of 24 processors | + | |
| - | Hello world from processor cnode0215, rank 17 out of 24 processors | + | |