7. Singularity Examples

Find below some examples of singuilarity containers built and run on the CAPRI platform.

7.1. Tensorflow + python packages

7.1.1. Description

One of the projects required a tensorflow installation plus some other softwares for computer vision. Instead of installing everithing system-wide a singularity file was built by customizing a docker image.

7.1.2. Singularity file

BootStrap: docker
From: tensorflow/tensorflow:latest-gpu-py3

%help
   This Singularity definition contains a TensorFlow-gpu installation

%post
   pip install scipy==1.2.1 six==1.12.0 numpy==1.15.4 pandas==0.24.2 matplotlib==3.0.2
   apt-get -y install libsm6 libxrender1 libxext6 libx11-6
   pip install keras==2.2.4 scikit-learn==0.20.2 opencv-python==3.4.2.17

%environment
   export LC_ALL=C

%runscript

%labels
   Author paoloemilio.mazzon

Note

The OS of the built singularity is Ubuntu 18.04 (which is different from the CAPRI one)

7.1.3. Build and run

On my PC:

sudo singularity build tflow_opencv.sif Singularity

On CAPRI (only the last line of the slurm script is described):

...
...
srun singularity exec --nv ./tflow_opencv.sif python script.py

7.2. Reuse and customize a local image

7.2.1. Description

A project required a Torch installation to perform som deep learning task. Since a tensorflow image was available locally we custimized that one instead of starting from scratch.

7.2.2. Singularity file

Note

The tflow_opencv.sif image is the one described in the Tensorflow + python packages example.

BootStrap: localimage
From: ./tflow_opencv.sif

%post
   pip install torch

%environment
   export LC_ALL=C

%runscript

%labels
   Author paoloemilio.mazzon

7.2.3. Build and run

On my PC:

sudo singularity build deeplearn.sif Singularity

On CAPRI (only the last line of the slurm script is described):

...
...
srun singularity exec --nv deeplearn.sif