Running Your Applications with Ease
Welcome!
In this workshop, we will go over using containers on HPC resources, like UCLA’s Hoffman2
This is Part I of my workshop on Containers.
This presentation can be found on our GitHub page
WS_container.pdf
WS_container.qmd
Containers are a powerful way to install and run scientific software.
Containers allow you to:
Containers allow for:
Image Ref: Hoffman2 source, Stampede2 source
Typically, to use your software on Hoffman2, you need to:
Caution
Easily install software with apt/yum 📦
Great if software requires MANY dependencies that would be complex installing on Hoffman2. ⛓️
Before diving into containers, it’s important to first understand virtualization, the technology that paved the way.
GIF from https://giphy.com/
Software runs directly on OS from the physical hardware
Typical applications are in this fashion
module load
softwareApplications running inside of a VM are running on a completely different set of (virtual) resources
A “Machine” within a “Machine”
Applications running inside of a container are running with the SAME kernal and physical resources as the host OS
A “OS” within a “OS”
Docker 🐳
Podman 📦
Security considerations 🛡️
To use Apptainer on Hoffman2, simply load the module:
Common Apptainer commands:
python3 test.py
inside the containerNote
Apptainer will NOT run on Hoffman2 login nodes.
Create 🛠️
Transfer ↪️
Run ▶️
1. Create 🛠️
Transfer
Run
.sif
$H2_CONTAINER_LOC
Create
Transfer
Run ▶️
Run Apptainer on your container:
Or run as a Batch (qsub) job
Create job script myjob.job
So….
Turns into
You can find the workshop material here:
This example will use Tensorflow
We will use TensorFlow to train a model from this dataset
EX1
directorytf-example.py
IT DOESN’T WORK!!! Need tensorflow installed!!!
tensorflow_2.7.1.sif
Tip
apptainer shell [container.sif]
apptainer exec [container.sif] [command]
EX2
directory
pytorch_gpu.py
fileLet’s run python3 pytorch_gpu.py
on a GPU node
--nv
option.
You can run MPI parallel software inside of containers. This example will compile and run a simple MPI code with a MPI-enabled container.
Commonly, containers for MPI software that you would find (or build) will have MPI installed inside the container.
You will also need to have a MPI build outside the container as well.
This Hybrid apporah will have the MPI build inside the container rely on the MPI implementation available outside on the host system
oneapi-hpckit_2025.0.2-0-devel-ubuntu24.04.sif
container filempiicx -o myMPIcode.x myMPIcode.c
inside the containerIn this example, we’ll run a parallel MPI container using NWChem, a popular chemistry software.
We will use a container with NWChem, built with MPI to run across multiple CPUs.
$H2_CONTAINER_LOC/h2-nwchem_7.0.2.sif
Note
echo $H2_CONTAINER_LOC
To run inside the container:
mpirun -np 5
in front of apptainer exec
Questions? Comments? 🤔
Charles Peterson cpeterson@oarc.ucla.edu