Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating branch #144

Merged
merged 8 commits into from
Feb 17, 2025
52 changes: 52 additions & 0 deletions apptainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## Apptainer images

Apptainer is a container platform designed to run complex applications on HPC clusters. The steps below were tested in Ubuntu 24.04.1 LTS.

### Installing Apptainer

Apptainer may be installed with the following instructions (there are issues with previous versions of Apptainer in Ubuntu 24):
````
sudo apt update
sudo apt install -y wget
cd /tmp
wget https://github.com/apptainer/apptainer/releases/download/v1.3.6/apptainer_1.3.6_amd64.deb
sudo apt install -y ./apptainer_1.3.6_amd64.deb
````

### Building Apptainer images

In spyro, the Apptainer image is based on the [Docker image](../docker/). Converting from Docker to Apptainer is more productive because Apptainer does not support image layers by design. Then, it is necessary to rerun all the instructions of the definition file when creating Apptainer images even when just one instruction is added (for example, for testing purposes).
````
export IMAGE_ID=$(sudo docker images -q devtag:1.0)
sudo docker save $IMAGE_ID -o devimg.tar
sudo chown $USER:$USER devimg.tar
sudo apptainer build devimg.sif docker-archive://devimg.tar
````

### Running Apptainer images

Before running the Apptainer image, it is necessary to create an [overlay filesystem](https://docs.sylabs.io/guides/3.6/user-guide/persistent_overlays.html) because the SIF container is read only and spyro requires writing to the filesystem.
````
apptainer overlay create --size 1024 /tmp/ext3_overlay.img
````

To execute the image in interactive mode:
````
apptainer shell --overlay /tmp/ext3_overlay.img -e devimg.sif
````

To execute the image in batch mode:
````
apptainer run --overlay /tmp/ext3_overlay.img -e devimg.sif <script>
````

### Running on Mintrop

In order to run code with Apptainer on Mintrop, you may add the following lines to your Slurm script:
````
module load apptainer
apptainer overlay create --size 1024 /tmp/ext3_overlay.img
apptainer run --overlay /tmp/ext3_overlay.img -e devimg.sif ./example.sh
````

where the script [example.sh](./example.sh) is provided in this directory to show how spyro code could be called.
4 changes: 4 additions & 0 deletions apptainer/example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

. /home/firedrake/firedrake/bin/activate
python3 -m pytest ../test
7 changes: 3 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ RUN . /home/firedrake/firedrake/bin/activate; pip install git+https://github.com

FROM spyro_base AS spyro_development

# For notebook development
RUN . /home/firedrake/firedrake/bin/activate; pip3 install notebook
EXPOSE 8888
# Profiling tools
RUN . /home/firedrake/firedrake/bin/activate; pip3 install -U memory_profiler

RUN . /home/firedrake/firedrake/bin/activate; pip3 install pytest
RUN . /home/firedrake/firedrake/bin/activate; pip3 install pytest pytest-cov
WORKDIR /home/firedrake
RUN echo "/home/firedrake/shared/spyro" >> /home/firedrake/firedrake/lib/python3.12/site-packages/shared.pth
4 changes: 2 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ docker run -it runtag:1.0

The Dockerfile may also be used to create a development environment. First, clone the git repository and then build the development image:
````
git clone https://github.com/Olender/spyro-1.git
cd spyro-1
git clone git@github.com:NDF-Poli-USP/spyro.git
cd spyro
git checkout <your_branch>
docker build -t devtag:1.0 -f docker/Dockerfile --target spyro_development docker
````
Expand Down
Loading