Using Containers to Run Jobs
Now that you know how to get containers, let's learn how to use them to run your computational tasks on AI-LAB.
Basic Container Usage
To run commands inside a container, you use singularity exec with either srun or sbatch.
Running a Simple Command
Let's start with a basic example using a Python container:
srun --mem=24G --cpus-per-task=15 --gres=gpu:1 --time=01:00:00 singularity exec --nv /ceph/container/python/python_3.10.sif python3 -c "print('Hello from AI-LAB')"
Command breakdown:
srun: Run on a compute node with specified resourcessingularity exec: Execute a command inside a container--nv: Enable NVIDIA GPU drivers (required for GPU jobs)/ceph/container/python/python_3.10.sif: Path to the containerpython3 -c "print('Hello from AI-LAB')": Command to run
Using Containers with sbatch
For longer jobs, enter nano jobname and create a batch script:
my_job.sh
#!/bin/bash
#SBATCH --job-name=my_python_job
#SBATCH --output=my_job.out
#SBATCH --error=my_job.err
#SBATCH --mem=24G
#SBATCH --cpus-per-task=15
#SBATCH --gres=gpu:1
#SBATCH --time=01:00:00
# Run Python script in container
singularity exec --nv /ceph/container/python/python_3.10.sif python3 my_script.py
Submit the job:
Check the results:
If the container you were planning to use is missing software required for your work, you can follow this guide for adding packages to a container. The guide will show how to create a copy of the container and modify it.