#!/bin/bash
#SBATCH --job-name=mysingularity
#SBATCH --error=opencv.%j.err
#SBATCH --output=opencv.%j.out
#SBATCH --partition=allgroups
#SBATCH --ntasks=1
#SBATCH --mem=1G
#SBATCH --time=00:05:00
cd $WORKING_DIR
#your working directory
srun singularity exec ./mysingularity.sif python script.py
#!/bin/bash
#SBATCH -J SingGPU
#SBATCH -o output_%j.txt
#SBATCH -e errors_%j.txt
#SBATCH -t 01:30:00
#SBATCH -n 1
#SBATCH -p allgroups
#SBATCH –-mem 100G
# requesting 1 GPU; set --gres=gpu:2 to use both GPUs
#SBATCH --gres=gpu:1
cd $WORKING_DIR
#your working directory
srun singularity exec --nv ./tensorflow.sif python script.py
Important!
You must request (at least) one GPU and you must pass the --nv flag to singularity.
You will find below some examples of Singularity containers built and run on the cluster platform.
One of the projects required a tensorflow installation plus some other softwares for computer vision. Instead of installing everything system-wide a singularity file was built by customizing a docker image.
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
Please note
The OS of the built singularity is Ubuntu 18.04 (which is different from the cluster one)
On your PC:
sudo singularity build tflow_opencv.sif Singularity
On the cluster (only the last line of the slurm script is described):
... ... srun singularity exec --nv ./tflow_opencv.sif python script.py
A project requires a Torch installation to perform some deep learning tasks. Since a tensorflow image is available locally we customize this instead of starting from scratch.
Please 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
On your PC:
sudo singularity build deeplearn.sif Singularity
On the cluster (only the last line of the slurm script is described):
... ... srun singularity exec --nv deeplearn.sif