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

update Docker container for Fujilupe #76

Merged
merged 14 commits into from
Jul 22, 2022
36 changes: 19 additions & 17 deletions bin/fastspecfit-setup.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
#!/bin/bash
# Simple script to run fastspecfit in interactive / development mode.
# Simple script to run fastspecfit in interactive / development mode. Run with
# % fastspecfit-setup.sh shifter
# % source fastspecfit-setup.sh env

if [ $1 = "shifter" ]; then
# Load the desigal Docker container using shifter
#SHIFTER=docker:desihub/fastspecfit:latest
SHIFTER=docker:desihub/fastspecfit:v0.2
SHIFTER=docker:desihub/fastspecfit:v1.0

echo 'Updating and loading the shifter image '$SHIFTER
echo 'Load the environment with: '
echo ' source fastspecfit-setup.sh env'
echo ' source ./fastspecfit-setup.sh env'

shifterimg pull $SHIFTER
shifter --image $SHIFTER bash
shifter --module=mpich-cle6 --image $SHIFTER bash
elif [ $1 = "env" ]; then
package=fastspecfit
#for package in fastspecfit; do
# echo Loading local check-out of $package
# export PATH=/global/homes/i/ioannis/code/desihub/$package/bin:$PATH
# export PYTHONPATH=/global/homes/i/ioannis/code/desihub/$package/py:$PYTHONPATH
#done

if [ "$NERSC_HOST" == "cori" ]; then
#export PATH=/opt/conda/bin:$PATH # NERSC hack!

export DESI_ROOT=/global/cfs/cdirs/desi
export FASTSPECFIT_TEMPLATES=$DESI_ROOT/science/gqp/templates/SSP-CKC14z
export DUST_DIR=/global/cfs/cdirs/cosmo/data/dust/v0_1

export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export KMP_AFFINITY=disabled
export MPICH_GNI_FORK_MODE=FULLCOPY
fi
export DESI_ROOT='/global/cfs/cdirs/desi'
export DUST_DIR='/global/cfs/cdirs/cosmo/data/dust/v0_1'
export FASTSPECFIT_TEMPLATES='/global/cfs/cdirs/desi/science/gqp/templates/SSP-CKC14z'

export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export KMP_AFFINITY=disabled
export MPICH_GNI_FORK_MODE=FULLCOPY

# Config directory nonsense
export TMPCACHE=$(mktemp -d)
Expand Down
3 changes: 2 additions & 1 deletion bin/jupyter-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ if __name__ == '__main__':
from ipykernel import kernelapp as app
app.launch_new_instance()
EOF
/opt/conda/bin/python $TMPSCRIPT --ignore-cwd -f $1
/usr/bin/python $TMPSCRIPT --ignore-cwd -f $1
#/opt/conda/bin/python $TMPSCRIPT --ignore-cwd -f $1
rm $TMPSCRIPT

# Clean up config directory nonsense.
Expand Down
14 changes: 7 additions & 7 deletions bin/mpi-fastspecfit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ program=$4
coadd_type=cumulative

#for package in desispec desitarget desiutil desimodel speclite specsim; do
for package in fastspecfit desispec; do
for package in fastspecfit; do
echo Loading local check-out of $package
export PATH=/global/homes/i/ioannis/code/desihub/$package/bin:$PATH
export PYTHONPATH=/global/homes/i/ioannis/code/desihub/$package/py:$PYTHONPATH
done
echo 'Loading local check-out of speclite'
export PYTHONPATH=/global/homes/i/ioannis/code/desihub/speclite:$PYTHONPATH
#echo 'Loading local check-out of speclite'
#export PYTHONPATH=/global/homes/i/ioannis/code/desihub/speclite:$PYTHONPATH

outdir_data=/global/cfs/cdirs/desi/users/ioannis/fastspecfit/vitiles
outdir_html=/global/cfs/cdirs/desi/users/ioannis/fastspecfit/vitiles
Expand All @@ -52,13 +52,13 @@ export MPICH_GNI_FORK_MODE=FULLCOPY
if [ $stage = "test" ]; then
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --help
elif [ $stage = "fastspec" ]; then
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 244 245 246 --outdir-data $outdir_data
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 80605 80606 80613 --outdir-data $outdir_data
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 142 --outdir-data $outdir_data
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 80648 80666 136 141 142 244 245 246 80605 80606 80613 --outdir-data $outdir_data
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --survey $survey --program $program --outdir-data $outdir_data
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --survey $survey --program $program --outdir-data $outdir_data
elif [ $stage = "fastphot" ]; then
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 80605 80606 80613 244 245 246 --outdir-data $outdir_data --fastphot --overwrite
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 80605 80606 80613 --outdir-data $outdir_data --fastphot
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 80648 80666 136 141 142 --outdir-data $outdir_data --fastphot
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --coadd-type $coadd_type --tile 244 245 246 80605 80606 80613 --outdir-data $outdir_data --fastphot
#time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --mp $mp --survey $survey --program $program --outdir-data $outdir_data --fastphot
elif [ $stage = "qafastspec" ]; then
time python /global/homes/i/ioannis/code/desihub/fastspecfit/bin/mpi-fastspecfit --makeqa --mp $mp --coadd-type $coadd_type --tile 80605 80606 80613 --outdir-data $outdir_data --outdir-html $outdir_html
Expand Down
2 changes: 2 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FastSpecFit Change Log
1.0 (not released yet)
----------------------

* Update Docker container and tag all dependencies [`PR #76`_].
* Numerous backwards-incompatible improvements and changes to the code engine
and data model in preparation for processing Fuji (EDR)+Guadalupe [`PR #69`_].
* Initial set-up of GitHub Actions and unit tests [`PR #61`_].
Expand All @@ -15,6 +16,7 @@ FastSpecFit Change Log
.. _`PR #60`: https://github.com/desihub/fastspecfit/pull/60
.. _`PR #61`: https://github.com/desihub/fastspecfit/pull/61
.. _`PR #69`: https://github.com/desihub/fastspecfit/pull/69
.. _`PR #76`: https://github.com/desihub/fastspecfit/pull/76

0.3 (2022-01-19)
----------------
Expand Down
181 changes: 47 additions & 134 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,163 +1,81 @@
FROM registry.services.nersc.gov/nersc/intel_cxx_fort_mpi_mkl_devel as builder
FROM ubuntu:22.04

RUN apt-get -y clean && apt -y update && apt install -y apt-utils && echo 4
RUN mkdir -p /src
WORKDIR /src

RUN apt-get -y clean && apt -y update && apt install -y apt-utils && apt -y upgrade && echo 1

RUN DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
make \
git \
file \
patch \
# pkg-config \
build-essential \
gfortran \
wget \
subversion \
emacs \
less \
# gcc \
zlib1g-dev \
# gfortran \
libbz2-dev \
libgsl-dev \
libcfitsio-dev \
libcfitsio-bin \
# python3 \
# python3-dev \
# python3-pip \
# python3-pil \
# python3-tk \
# # Remove APT files
git \
pkg-config \
libbz2-dev \
libgsl-dev \
libssl-dev \
# mpich \
python3-dev \
python3-pip \
# python3-mpi4py \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo 'PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh

RUN wget -nv https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \
bash miniconda.sh -b -p /opt/conda && \
conda config --add channels intel && \
conda config --set always_yes yes && \
conda update conda && \
conda install python=3.9 pip numpy scipy && \
conda clean -a -y

ENV CC icc
ENV CXX icpc
ENV LDSHARED icc -shared
ENV CFLAGS -O3 -g -fPIC -std=gnu99 -pthread -x=haswell -ax=knl
ENV ARCH_FLAGS ""
# python = python3
RUN ln -s "$(which python3)" /usr/bin/python

ENV PYTHON python3
ENV PYTHON_CONFIG python3-config
ENV PYTHON_SCRIPT "/usr/bin/env python3"
ARG mpich=4.0.2
ARG mpich_prefix=mpich-$mpich

RUN mkdir -p /src
WORKDIR /src
ENV FFLAGS="-fallow-argument-mismatch" \
FCFLAGS="-fallow-argument-mismatch"

ENV BLAS -L${MKLROOT}/lib/intel64 -lmkl_rt -fopenmp -lpthread -limf -lsvml -ldl
ENV CPPFLAGS -I${MKLROOT}/include

RUN wget --no-check-certificate -nv https://www.mpich.org/static/downloads/3.4.3/mpich-3.4.3.tar.gz \
&& tar xvzf mpich-3.4.3.tar.gz \
&& cd mpich-3.4.3 \
RUN wget --no-check-certificate -nv https://www.mpich.org/static/downloads/$mpich/$mpich_prefix.tar.gz \
&& tar xvzf $mpich_prefix.tar.gz \
&& cd $mpich_prefix \
&& ./configure \
&& make -j4 \
&& make -j 4 \
&& make install \
&& make clean \
&& cd .. && rm -Rf mpich-3.4.3
# defaults to installing in /usr/local

# mpi4py / mpicc can't handle -ax=knl
ENV CFLAGS -O3 -g -fPIC -std=gnu99 -pthread
RUN git clone https://github.com/mpi4py/mpi4py.git \
&& (cd mpi4py \
&& python setup.py build \
&& python setup.py install) \
&& rm -Rf mpi4py

# Pip installs -- built from source
RUN pip --no-cache-dir install fitsio && echo 1
&& cd .. \
&& rm -rf $mpich_prefix

RUN /sbin/ldconfig

######## Stage 2 ########
FROM registry.services.nersc.gov/nersc/intel_cxx_fort_mpi_mkl_runtime

ENV PYTHON python3
ENV PYTHON_CONFIG python3-config
ENV PYTHON_SCRIPT "/usr/bin/env python3"
RUN echo 'PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh

RUN rm /root/.profile

RUN apt -y update && apt install -y apt-utils \
&& DEBIAN_FRONTEND=noninteractive \
apt install -y --no-install-recommends \
make \
git \
file \
pkg-config \
wget \
# gcc \
zlib1g-dev \
# gfortran \
subversion \
emacs \
less \
patch \
libbz2-dev \
libgsl-dev \
libcfitsio-dev \
libcfitsio-bin \
imagemagick \
# # Remove APT files
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt/conda /opt/conda

RUN conda update --no-deps certifi
RUN for x in \
setuptools \
wheel \
numpy \
setuptools \
pytest \
numpy==1.22.4 \
scipy \
matplotlib \
astropy \
numba \
pyyaml \
requests \
scikit-learn \
healpy \
fitsio \
numba \
mpi4py \
seaborn \
photutils \
matplotlib \
ipython \
ipykernel \
h5py \
pytest \
configobj \
sqlalchemy \
; do pip3 install $x; done \
&& rm -Rf /root/.cache/pip \
&& echo 3

WORKDIR /src

# python = python3
RUN ln -s $(which python3) /usr/bin/python

WORKDIR /src
&& echo 1

ENV DESIMODEL /src/desimodel
# ENV DESIMODEL /src/desimodel
ENV DESIUTIL_VERSION 3.2.5
ENV DESIMODEL_VERSION 0.17.0
ENV DESITARGET_VERSION 2.5.0
ENV DESISPEC_VERSION 0.53.2
ENV SPECLITE_VERSION v0.16
ENV FASTSPECFIT_VERSION main

# Install desiutil, fastspecfit, and then the other desihub dependencies.
RUN python -m pip install git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil

RUN git clone https://github.com/desihub/fastspecfit.git@{FASTSPECFIT_VERSION} \
&& cd $package \
&& git describe --always \
&& python -m pip install -r requirements.txt \
&& python setup.py install \
&& echo 1
RUN pip3 install git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil
RUN pip3 install git+https://github.com/desihub/desimodel.git@${DESIMODEL_VERSION}#egg=desimodel
RUN pip3 install git+https://github.com/desihub/desitarget.git@${DESITARGET_VERSION}#egg=desitarget
RUN pip3 install git+https://github.com/desihub/speclite.git@${SPECLITE_VERSION}#egg=speclite
RUN pip3 install git+https://github.com/desihub/desispec.git@{DESISPEC_VERSION}#egg=desispec
RUN pip3 install git+https://github.com/desihub/fastspecfit.git

ENV PYTHONPATH /src/fastspecfit/py
ENV PATH /src/fastspecfit/bin:/opt/conda/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Expand Down Expand Up @@ -186,9 +104,4 @@ RUN echo "export PS1='[container] \\u@\\h:\\w$ '" >> $HOME/.bashrc \
&& chmod -R a+rwX $HOME/.ipython \
&& echo 2

# Curses upon you, astropy
RUN wget -O /opt/conda/lib/python3.9/site-packages/astropy/utils/iers/data/Leap_Second.dat \
https://raw.githubusercontent.com/astropy/astropy/master/astropy/utils/iers/data/Leap_Second.dat \
&& rm $HOME/.wget-hsts

LABEL Maintainer="John Moustakas jmoustakas@siena.edu"
14 changes: 8 additions & 6 deletions docker/README → docker/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Build a Docker container for fastspecfit.
=========================================

Build a cross-platform docker container as documented [here](https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide), [here](https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/), and [here](https://docs.nersc.gov/development/shifter/how-to-use/).
```
./build.sh
docker push desihub/fastspecfit:latest
export DOCKER_BUILDKIT=0
export COMPOSE_DOCKER_CLI_BUILD=0

docker tag desihub/fastspecfit:latest desihub/fastspecfit:v0.3
docker push desihub/fastspecfit:v0.3
docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t desihub/fastspecfit:v1.0 .
docker buildx build --platform linux/amd64,linux/arm64/v8 --push -t desihub/fastspecfit:latest .
```

To enter the container (with a shell prompt) on a laptop do:
Expand All @@ -16,8 +18,8 @@ docker run -it desihub/fastspecfit:latest
```
or
```
docker pull desihub/fastspecfit:v0.2
docker run -it desihub/fastspecfit:v0.2
docker pull desihub/fastspecfit:v1.0
docker run -it desihub/fastspecfit:v1.0
```

Or at NERSC:
Expand Down
14 changes: 0 additions & 14 deletions docker/build.sh

This file was deleted.