Skip to content

Commit

Permalink
Merge branch 'topic/default/apptainer' into 'branch/default'
Browse files Browse the repository at this point in the history
First apptainer .def file

See merge request fluiddyn/fluidsim!386
  • Loading branch information
paugier committed Jun 18, 2024
2 parents c997368 + 0b13e3e commit 4d95385
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
42 changes: 42 additions & 0 deletions doc/apptainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Install Fluidsim from source in an Apptainer container

The directory `fluidsim/doc/apptainer` contains what is needed to run Fluidsim
with Apptainer. See also
https://gricad-doc.univ-grenoble-alpes.fr/hpc/softenv/container/.

## Build the image locally on a node

From the host:

```sh
mkdir ~/apptainer
cd ~/apptainer
wget https://foss.heptapod.net/fluiddyn/fluidsim/-/raw/topic/default/apptainer/doc/apptainer/image-fluidsim.def
apptainer build image-fluidsim.sif image-fluidsim.def
```

## Run the image to install Fluidsim from source

From the host (a node of the cluster!):

```sh
cd ~/apptainer
apptainer shell --no-home image-fluidsim.sif
```

From the container:

```sh
python -m venv venv-fluidsim
. venv-fluidsim/bin/activate
HDF5_MPI="ON" pip install --no-binary=h5py h5py pytest pytest-mpi
python -c 'import h5py; h5py.run_tests()'
hg clone https://foss.heptapod.net/fluiddyn/fluidsim
cd fluidsim/
pip install ".[test,mpi,fft]"
pytest --pyargs fluidsim
pip install fluidfft-fftw fluidfft-fftwmpi fluidfft-mpi_with_fftw
mpirun -np 2 pytest --pyargs fluidsim
pip install fluidfft-p3dfft
pip install fluidfft-pfft
```
32 changes: 32 additions & 0 deletions doc/apptainer/hgrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[ui]
# TODO: correct this line.
username=user_apptainer
editor=nano
# another alternative
# editor=emacs -nw -Q
tweakdefaults = True
ignore = ~/.hgignore

[alias]
lg = log -G
up = up -v

[extensions]
hgext.extdiff =
# only to use Mercurial with GitHub and Gitlab
hggit =
# specific extension for FluidDyn dev
hgfluiddyn =
# more advanced extensions (really useful for FluidDyn dev)
churn =
shelve =
rebase =
absorb =
evolve =
topic =

[extdiff]
cmd.meld =

# [subrepos]
# git:allowed = true
54 changes: 54 additions & 0 deletions doc/apptainer/image-fluidsim.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
BootStrap: docker
From: python:3.11

%post
apt-get -y update
apt-get -y install mercurial git less meld nano

apt-get install -y --no-install-recommends \
libfftw3-dev libfftw3-mpi-dev openmpi-bin libhdf5-openmpi-dev libopenblas-dev \
gfortran

mkdir -p /root/.local/include
mkdir -p /root/.local/lib
export PATH=/root/.local/bin:$PATH
export CPATH=/root/.local/include
export LIBRARY_PATH=/root/.local/lib
export LD_LIBRARY_PATH=/root/.local/lib

python -m pip install pipx

pipx install mercurial
pipx inject mercurial hg-git hg-evolve hg-fluiddyn
wget https://foss.heptapod.net/fluiddyn/fluidsim/-/raw/topic/default/apptainer/doc/apptainer/hgrc -O ~/hgrc

pipx install pdm
pipx install nox

ln -s /usr/include/fftw* /root/.local/include
ln -s /usr/lib/x86_64-linux-gnu/libfftw3* /root/.local/lib

wget https://foss.heptapod.net/fluiddyn/fluidfft/raw/branch/default/doc/install/install_p3dfft.sh -O ./install_p3dfft.sh
chmod +x install_p3dfft.sh
export FCFLAGS="-w -fallow-argument-mismatch -O2"
export FFLAGS="-w -fallow-argument-mismatch -O2"
./install_p3dfft.sh

wget https://foss.heptapod.net/fluiddyn/fluidfft/raw/branch/default/doc/install/install_pfft.sh -O ./install_pfft.sh
chmod +x install_pfft.sh
./install_pfft.sh

%startscript
mkdir -p home

%environment
export LC_ALL=C
export PATH=/root/.local/bin:$PATH
export CPATH=/root/.local/include
export LIBRARY_PATH=/root/.local/lib
export LD_LIBRARY_PATH=/root/.local/lib
export HOME=$HOME/apptainer/home
export HGRCPATH=/root/hgrc

%labels
Author Pierre Augier
9 changes: 9 additions & 0 deletions doc/build-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ export MESONPY_EDITABLE_VERBOSE=1
See
https://meson-python.readthedocs.io/en/latest/how-to-guides/editable-installs.html#verbose-mode

## Installation with Apptainer

```{toctree}
---
maxdepth: 1
---
apptainer/README.md
```

[conda-forge]: https://conda-forge.org/
[evolve]: https://www.mercurial-scm.org/doc/evolution/
[mercurial]: https://www.mercurial-scm.org/
Expand Down

0 comments on commit 4d95385

Please sign in to comment.