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

Updates for EL9 and Apptainer #31

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions ROOT6/Dockerfile → MAIN/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04

LABEL maintainer="Mark Anderson <[email protected]>"
LABEL maintainer="Will Parker <[email protected]>"

# Switch default shell to bash
SHELL ["/bin/bash", "-c"]
Expand All @@ -22,7 +22,7 @@ RUN apt-get update && apt-get install -y gcc g++ gfortran \
graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev libxml2-dev libkrb5-dev \
libgsl0-dev emacs wget git tar curl nano vim rsync strace valgrind make cmake \
libxpm-dev libxft-dev libxext-dev libcurl4-openssl-dev libbz2-dev latex2html \
python3 python3-dev python3-pip python3-venv python2 python2-dev python-is-python3
python3 python3-dev python3-pip python3-venv python-is-python3

# Install Python packages
RUN python3 -m pip install --upgrade --no-cache-dir pip && \
Expand Down Expand Up @@ -66,11 +66,16 @@ RUN wget https://cern.ch/geant4-data/releases/geant$GEANT4_VERSION.tar.gz && \
rm -rf geant$GEANT4_VERSION.tar.gz

# Install ROOT 6 binary
ARG ROOT_VERSION=6.22.08
ARG ROOT_VERSION=6.32.02
WORKDIR $SOFTWAREDIR
RUN wget https://root.cern/download/root_v$ROOT_VERSION.Linux-ubuntu20-x86_64-gcc9.3.tar.gz && \
tar xzfv root_v$ROOT_VERSION.Linux-ubuntu20-x86_64-gcc9.3.tar.gz && \
rm -rf root_v$ROOT_VERSION.Linux-ubuntu20-x86_64-gcc9.3.tar.gz

RUN wget https://root.cern/download/root_v$ROOT_VERSION.source.tar && \
tar xvf root_v6.32.02.source.tar && \
mv root-6.32.02 root && \
mkdir root-build && cd root-build && \
cmake -Droofit=ON -Dfortran=OFF -Dfftw3=ON -Dgsl=ON -Dgdml=ON -Dmathmore=ON -Dclad=OFF -Dbuiltin_tbb=OFF -Dimt=OFF ../root && \
make -j 4 && \
rm ../root_v$ROOT_VERSION.source.tar

# Cleanup the cache to make the image smaller
RUN apt-get autoremove -y && apt-get clean -y
Expand Down
127 changes: 127 additions & 0 deletions MAIN/GENIE.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
FROM ubuntu:20.04

LABEL maintainer="Will Parker <[email protected]>"

# Switch default shell to bash
SHELL ["/bin/bash", "-c"]

# Create place to copy scripts to
RUN mkdir /home/scripts
COPY scripts/build-rat.sh /home/scripts
COPY scripts/setup-env.sh /home/scripts
COPY scripts/setup-genie.sh /home/scripts
COPY scripts/docker-entrypoint.sh /usr/local/bin/

ENV DEBIAN_FRONTEND=noninteractive

ARG SOFTWAREDIR=/home/software
RUN mkdir -p ${SOFTWAREDIR}

RUN apt-get update && apt-get install -y gcc g++ gfortran \
libssl-dev libpcre3-dev xlibmesa-glu-dev libglew1.5-dev \
libftgl-dev libmysqlclient-dev libfftw3-dev libcfitsio-dev \
graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev libxml2-dev libkrb5-dev \
libgsl0-dev emacs wget git tar curl nano vim rsync strace valgrind make cmake \
libxpm-dev libxft-dev libxext-dev libcurl4-openssl-dev libbz2-dev latex2html libxerces-c-dev\
python3 python3-dev python3-pip python3-venv python-is-python3

# Install Python packages
RUN python3 -m pip install --upgrade --no-cache-dir pip && \
python3 -m pip install --upgrade --no-cache-dir setuptools && \
python3 -m pip install --no-cache-dir pipx && \
python3 -m pip install --no-cache-dir requests pytz python-dateutil \
ipython numpy scipy matplotlib

# Install SCons via pip (quicker and simpler than from source)
ARG SCONS_VERSION=3.1.2
RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install scons==$SCONS_VERSION

# Fetch and install TensorFlow C API v1.15.0 and cppflow
ARG TENSORFLOW_VERSION=2.5.3
ARG TENSORFLOW_TAR_FILE=libtensorflow-cpu-linux-x86_64-$TENSORFLOW_VERSION.tar.gz
WORKDIR $SOFTWAREDIR
RUN wget https://storage.googleapis.com/tensorflow/libtensorflow/$TENSORFLOW_TAR_FILE && \
tar -C /usr/local -xzf $TENSORFLOW_TAR_FILE && \
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib && \
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib && \
rm $TENSORFLOW_TAR_FILE && \
git clone --single-branch https://github.com/serizba/cppflow && \
cd cppflow && \
git checkout 883eb4c526979dae56f921571b1ab93df85a0a0d

# Fetch and install GEANT4 from source
ARG GEANT4_VERSION=4.10.00.p04
WORKDIR $SOFTWAREDIR
RUN wget https://cern.ch/geant4-data/releases/geant$GEANT4_VERSION.tar.gz && \
mkdir geant$GEANT4_VERSION && mkdir geant$GEANT4_VERSION-source && mkdir geant$GEANT4_VERSION-build && \
tar zxvf geant$GEANT4_VERSION.tar.gz -C geant$GEANT4_VERSION-source --strip-components 1 && \
pushd geant$GEANT4_VERSION-source && \
wget https://github.com/JamesJieranShen/geant4/commit/3ec1153a22a76c181d45a8ee67fb3121cadff1e6.patch -O out.patch && \
patch -p1 < out.patch && \
popd && \
cd geant$GEANT4_VERSION-build && \
cmake -DCMAKE_INSTALL_PREFIX=../geant$GEANT4_VERSION \
-DGEANT4_INSTALL_DATA=ON \
-DGEANT4_BUILD_CXXSTD=c++11 \
-DGEANT4_USE_GDML=ON \
../geant$GEANT4_VERSION-source && \
make -j$(nproc) && make install && \
cd .. && \
rm -rf geant$GEANT4_VERSION-source && \
rm -rf geant$GEANT4_VERSION-build && \
rm -rf geant$GEANT4_VERSION.tar.gz

# Pythia6 -- need to be built before root
RUN mkdir -p ${SOFTWAREDIR}/pythia6
WORKDIR ${SOFTWAREDIR}/pythia6
RUN wget https://raw.githubusercontent.com/GENIE-MC/Generator/29dc1a99ae56161f86be455c17fddd8be86666ac/src/scripts/build/ext/build_pythia6.sh
RUN source build_pythia6.sh 6.4.28
WORKDIR ${SOFTWAREDIR}
ENV PYTHIA6=${SOFTWAREDIR}/pythia6/v6_428

# Install ROOT 6 binary
ARG ROOT_VERSION=6.28.06
WORKDIR $SOFTWAREDIR

RUN wget https://root.cern/download/root_v$ROOT_VERSION.source.tar && \
tar xvf root_v${ROOT_VERSION}.source.tar && \
mv root-${ROOT_VERSION} root && \
mkdir root-build && cd root-build && \
cmake -Droofit=ON -Dfortran=OFF -Dfftw3=ON -Dgsl=ON -Dgdml=ON -Dmathmore=ON -Dclad=OFF -Dbuiltin_tbb=OFF -Dimt=OFF -Dpythia6=ON -DPYTHIA6_DIR=${SOFTWAREDIR}/pythia6/v6_428 ../root && \
make -j $(nproc) && \
rm ../root_v$ROOT_VERSION.source.tar

RUN apt-get -y update && apt-get -y upgrade && apt-get -y install liblog4cpp5-dev
RUN wget https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.5.4.tar.gz -O LHAPDF-6.5.4.tar.gz && \
tar xf LHAPDF-6.5.4.tar.gz && rm LHAPDF-6.5.4.tar.gz && mv LHAPDF-6.5.4 LHAPDF6-src
RUN mkdir -p ${SOFTWAREDIR}/LHAPDF6
WORKDIR ${SOFTWAREDIR}/LHAPDF6-src
RUN ./configure --prefix=${SOFTWAREDIR}/LHAPDF6 && make -j$(nproc) && make install
WORKDIR ${SOFTWAREDIR}
RUN rm -rf ${SOFTWAREDIR}/LHDPDF6-src
ENV LHAPDF6=${SOFTWAREDIR}/LHAPDF6

RUN git clone --depth=1 --branch=R-3_04_02 https://github.com/GENIE-MC/Generator.git genie-src
ARG GENIE=${SOFTWAREDIR}/genie-src
WORKDIR ${GENIE}
RUN pushd ${SOFTWAREDIR}/root-build/bin && source thisroot.sh && popd && \
source ${SOFTWAREDIR}/geant4.10.00.p04/bin/geant4.sh && \
./configure --enable-atmo --enable-fnal --enable-t2k --enable-nucleon-decay --enable-vle-extension\
--prefix=${SOFTWAREDIR}/genie \
--enable-lhapdf6 \
--with-lhapdf6-lib=${SOFTWAREDIR}/LHAPDF6/lib \
--with-lhapdf6-inc=${SOFTWAREDIR}/LHAPDF6/include \
--with-pythia6-lib=${SOFTWAREDIR}/pythia6/v6_428/lib &&\
make -j$(nproc) && make install && \
# # GENIE requires these files to be present at runtime, but doesn't install them
cp -r config ${SOFTWAREDIR}/genie/ && \
cp -r data ${SOFTWAREDIR}/genie/ && \
cp -r src ${SOFTWAREDIR}/genie/
ENV GENIE=${SOFTWAREDIR}/genie

# Cleanup the cache to make the image smaller
RUN apt-get autoremove -y && apt-get clean -y

# Set up the environment when entering the container
WORKDIR /home
ENTRYPOINT ["docker-entrypoint.sh"]
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![https://img.shields.io/badge/hosted-dockerhub-blue](https://img.shields.io/badge/hosted-dockerhub-blue)](https://hub.docker.com/r/snoplus/rat-container)


Singularity and Docker recipes to build a SNO+ environment for RAT.
Apptainer (formerly Singularity) and Docker recipes to build a SNO+ environment for RAT.

For regular usage, simply download the pre-built container with the following instructions for your container platform of choice. For advanced users, see the build instructions below.

Expand All @@ -19,60 +19,60 @@ As of ***November 1, 2020*** Docker is implementing an inactive image removal po
- Can build any version of RAT
- GUI output support on all operating systems
- TensorFlow and CppFlow (CPU-only for the time being)
- Singularity and Docker compatibility
- Apptainer and Docker compatibility
- *Cluster-compatible

*The image can be uploaded manually, pulled directly (if the cluster firewall permits) or run from /cvmfs; however, the cvmfs
image is not always up-to-date with the repo version. This has been [identified as an issue](https://github.com/snoplus/rat-container/issues/8) with a possible solution posed.

# [PLEASE READ]

1. Singularity and Docker are similar tools but operate slightly differently. Singularity acts more like an overlay, where
1. Apptainer and Docker are similar tools but operate slightly differently. Apptainer acts more like an overlay, where
you have access to your filesystem as you would **outside** the container (with the same rights as you'd have outside),
whereas Docker provides you with an isolated virtual filesystem (meaning you **can't** access your files from outside
the container). In summary, it is best to **mount** whatever directories you may need when running the container, whether
in Docker or Singularity (see the section "**To write/execute files from directories outside of RAT/launch
in Docker or Apptainer (see the section "**To write/execute files from directories outside of RAT/launch
directory**" below).

2. Regardless of whether you download or build the container, you can use and develop RAT as you see fit as it is external
to the container.

3. Instructions to install Singularity can be found [here.](https://github.com/sylabs/singularity/blob/master/INSTALL.md) For
3. Instructions to install Apptainer can be found [here.](https://github.com/apptainer/apptainer/blob/v1.0.0-rc.1/INSTALL.md) For
Docker, instructions for each platform can be found [here.](https://docs.docker.com/install/#supported-platforms)
- **For Singularity, version 3.2+ is required**
- **For Docker, version 19.0+ is required**

4. As the DIRAC system no longer supports SL6, there is no longer a need to maintain an SL6 version when pushing new RAT releases to cvmfs. Therefore, the only image offered here is based on SL7.

5. **To be clear, if you wish to use the prebuilt image, then you do NOT need to clone this repo; simply follow the
4. **To be clear, if you wish to use the prebuilt image, then you do NOT need to clone this repo; simply follow the
instructions below.**

# New Video Tutorial (slightly outdated - no longer necessary to source the setup-env.sh on startup)
5. On Cedar, when using apptainer, first do:
```
module load apptainer
```

# New Video Tutorial (slightly outdated - no longer necessary to source the setup-env.sh on startup, and we no longer have separate ROOT5/6 tags, just MAIN)
- [Available here (Requires SNO+ DocDB access)](https://www.snolab.ca/snoplus/private/DocDB/0062/006281/001/RAT%20container%20tutorial.mp4)

# To download the pre-built container
**If on a shared system/cluster**, Singularity should be available so use the following command to obtain the latest
**If on a shared system/cluster**, Apptainer should be available so use the following command to obtain the latest
version of the container:
```
singularity pull --name rat-container.sif docker://snoplus/rat-container:root5
apptainer pull --name rat-container.sif docker://snoplus/rat-container:main
```
The tag (in the above command, `root5`) can be replaced with the desired tag.

Ensure that the Singularity version you are using is **&ge;3.2**
The tag (in the above command, `main`) could be replaced with the desired tag (although currently, only MAIN is maintained).

At the moment, certain clusters (like Cedar) have firewall rules preventing access to SingularityHub. There is a version of
the image located at `/cvmfs/snoplus.egi.eu/sl7/sw/containers/rat-container.sif` but keep in mind that it may not always be
the image located at `/cvmfs/snoplus.egi.eu/el9/sw/containers/rat-container.sif` but keep in mind that it may not always be
the latest version (this shouldn't matter if you are simply building/running RAT).

***
**If on your own local machine**, Docker should be used as it is easier to install.
The command to obtain the latest version of the container for Docker is:
```
docker pull snoplus/rat-container:root5
docker pull snoplus/rat-container:main
```
The tag (in the above command, `root5`) can be replaced with the desired tag.
The tag (in the above command, `main`) can be replaced with the desired tag.

Docker doesn't actually create a file in your working directory in the same way that Singularity does; rather, it
Docker doesn't actually create a file in your working directory in the same way that Apptainer does; rather, it
downloads the image layers and adds an entry to your local **Docker registry** which can be viewed by going:
```
docker images
Expand All @@ -87,18 +87,18 @@ This difference doesn't have an effect on how the container is actually used.
- Enter the following command, filling in the path to RAT with your own.
This will mount your RAT repo to the directory `/rat` inside the container:

For *Singularity*:
For *Apptainer*:
```
singularity shell -B path/to/rat:/rat rat-container.sif
apptainer shell -B path/to/rat:/rat rat-container.sif
```
For *Docker*:
```
docker run -ti --init --rm -v /absolute/path/to/rat:/rat snoplus/rat-container
```
*Note* - the `-v` flag operates the same as `-B` in Singularity BUT you **must** provide it with an absolute path (one starting at /);
*Note* - the `-v` flag operates the same as `-B` in Apptainer BUT you **must** provide it with an absolute path (one starting at /);
relative paths (the path from where you are now) will **not** work.

- Once in the container, Singularity users need to run the following:
- Once in the container, Apptainer users need to run the following:
```
source /home/scripts/setup-env.sh
```
Expand All @@ -115,7 +115,7 @@ This difference doesn't have an effect on how the container is actually used.
- RAT is now ready to use! Look at the instructions below for how to run it

***
**To exit the container (Singularity and Docker)**:
**To exit the container (Apptainer and Docker)**:
```
exit
```
Expand All @@ -126,9 +126,9 @@ exit
- First, get a shell into the container with your RAT bound into it:
(It is **important** to **mount your rat directory to /rat** as the build scripts look there for it!)

For *Singularity*:
For *Apptainer*:
```
singularity shell -B path/to/rat:/rat rat-container.sif
apptainer shell -B path/to/rat:/rat rat-container.sif
```
For *Docker*:
```
Expand All @@ -142,7 +142,7 @@ directories, additional bind mounts are necessary (see below).
(This is based on CERN's documentation for [running ROOT with graphics](https://hub.docker.com/r/rootproject/root-ubuntu16/))

- The process is different on each OS but I will outline steps here to make it work on each. Note that these instructions
assume that since you are on your own machine, you are using **Docker**. Singularity may work with graphics as it is, but
assume that since you are on your own machine, you are using **Docker**. Apptainer may work with graphics as it is, but
these Docker solutions are the only ones that are tested and confirmed to be working.

For **Linux**:
Expand Down Expand Up @@ -184,9 +184,9 @@ directories, additional bind mounts are necessary (see below).
```
- Then, run the container:

For *Singularity*:
For *Apptainer*:
```
singularity shell -B path/to/rat:/rat rat-container.sif
apptainer shell -B path/to/rat:/rat rat-container.sif
```
For *Docker*:
```
Expand All @@ -203,12 +203,12 @@ directories, additional bind mounts are necessary (see below).

***
**To write/execute files from directories outside of RAT/launch directory**:
- Add additional bind mounts to your Singularity or Docker command
- Add additional bind mounts to your Apptainer or Docker command
- Example:

For *Singularity*:
For *Apptainer*:
```
singularity shell -B path/to/rat:/rat,/other/path:/stuff rat-container.sif
apptainer shell -B path/to/rat:/rat,/other/path:/stuff rat-container.sif
```
For *Docker*:
```
Expand All @@ -232,13 +232,13 @@ To build, you must have **root permissions** and **Docker installed on your mach
To rebuild the container:

1. Clone this repository
2. Navigate into either `/ROOT5` or `/ROOT6` depending on which you would like to build off of
2. Navigate into `MAIN`
3. Edit `Dockerfile`, which is the recipe on what you would like to put into your container
4. Once you are happy with your changes, navigate back to the root of the repository and run:
```
docker build -t YOUR_CONTAINER_TAG -f ROOT5/Dockerfile .
docker build -t YOUR_CONTAINER_TAG -f MAIN/Dockerfile .
```
where `YOUR_CONTAINER_TAG` is the name you would like to give to your container. Also, ensure you change `ROOT5` to `ROOT6` if using that version
where `YOUR_CONTAINER_TAG` is the name you would like to give to your container. Also, ensure you change `MAIN` to whichever version you want

5. This will build your container with your tag name, which you can then use in the same way as in the above guide, but instead of
```
Expand Down Expand Up @@ -290,6 +290,6 @@ RAT. Please review the instructions for how to update RAT above for the correct
**When I try to open the TBrowser/another GUI app, it doesn't show**
- This is a known issue, and happens for two reasons. If you are trying to use the Docker version on your own machine, Docker
does not have access to the display by default so there is some configuration required.
- The other issue is if you are trying to do this on a cluster with the Singularity version, you will notice the same thing.
- The other issue is if you are trying to do this on a cluster with the Apptainer version, you will notice the same thing.
Because you are remotely connected, the display is not configured by default to also connect.
- Known methods for getting a GUI working are listed in a section above for each OS under Docker.
Loading