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

Reduce number of packages installed in docker images #193

Merged
merged 3 commits into from
May 10, 2023
Merged
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
249 changes: 48 additions & 201 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,141 +35,31 @@ ARG EXAFMM_VERSION

WORKDIR /tmp

# Install dependencies available via apt-get.
# - First set of packages are required to build and run Bempp-cl.
# - Second set of packages are recommended and/or required to build
# documentation or tests.
# - Third set of packages are optional, but required to run gmsh
# pre-built binaries.
# - Fourth set of packages are optional, required for meshio.
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -qq update && \
apt-get -yq --with-new-pkgs -o Dpkg::Options::="--force-confold" upgrade && \
apt-get -y install \
cmake \
git \
ipython3 \
pkg-config \
python-is-python3 \
python3-dev \
python3-matplotlib \
python3-mpi4py \
python3-pip \
python3-pyopencl \
python3-scipy \
python3-setuptools \
jupyter \
wget && \
apt-get -y install \
libfftw3-dev \
libfltk-gl1.3 \
libfltk-images1.3 \
libfltk1.3 \
libfreeimage3 \
libgl2ps1.4 \
libglu1-mesa \
libilmbase25 \
libjxr0 \
libocct-data-exchange-7.5 \
libocct-foundation-7.5 \
libocct-modeling-algorithms-7.5 \
libocct-modeling-data-7.5 \
libocct-ocaf-7.5 \
libocct-visualization-7.5 \
libopenblas-dev \
libopenexr25 \
libopenjp2-7 \
libraw-dev \
libtbb2 \
libxcursor1 \
libxinerama1 && \
apt-get -y install \
python3-lxml && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Python packages (via pip)
RUN pip3 install --no-cache-dir "numpy>=1.21,<1.23" numba>=0.55.2 meshio>=4.0.16 && \
pip3 install --no-cache-dir flake8 pytest pydocstyle pytest-xdist

# Download Install Gmsh SDK
RUN cd /usr/local && \
wget -nc --quiet http://gmsh.info/bin/Linux/gmsh-${GMSH_VERSION}-Linux64-sdk.tgz && \
tar -xf gmsh-${GMSH_VERSION}-Linux64-sdk.tgz && \
rm gmsh-${GMSH_VERSION}-Linux64-sdk.tgz

ENV PATH=/usr/local/gmsh-${GMSH_VERSION}-Linux64-sdk/bin:$PATH

RUN git clone -b v${EXAFMM_VERSION} https://github.com/exafmm/exafmm-t.git
RUN cd exafmm-t && sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 setup.py install

# Clear /tmp
RUN rm -rf /tmp/*

WORKDIR /root

########################################

FROM ubuntu:22.04 as bempp-dev-env-with-dolfin
LABEL maintainer="Matthew Scroggs <[email protected]>"
LABEL description="Bempp-cl development environment with FEniCS"

ARG GMSH_VERSION
ARG MAKEFLAGS
ARG EXAFMM_VERSION

WORKDIR /tmp

# Install dependencies
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -qq update && \
apt-get -yq --with-new-pkgs -o Dpkg::Options::="--force-confold" upgrade && \
apt-get -y install \
cmake \
git \
ipython3 \
pkg-config \
python-is-python3 \
python3-dev \
python3-mpi4py \
python3-pip \
python3-pyopencl \
python3-setuptools \
jupyter \
wget && \
apt-get -y install \
libfftw3-dev \
libfltk-gl1.3 \
libfltk-images1.3 \
libfltk1.3 \
libfreeimage3 \
libgl2ps1.4 \
libglu1-mesa \
libilmbase25 \
libjxr0 \
libocct-data-exchange-7.5 \
libocct-foundation-7.5 \
libocct-modeling-algorithms-7.5 \
libocct-modeling-data-7.5 \
libocct-ocaf-7.5 \
libocct-visualization-7.5 \
libopenblas-dev \
libopenexr25 \
libopenjp2-7 \
libraw-dev \
libtbb2 \
libxcursor1 \
libxinerama1
RUN pip3 install --no-cache-dir meshio>=4.0.16 \
numba numpy==1.20 scipy matplotlib && \
pip3 install --no-cache-dir flake8 pytest pydocstyle pytest-xdist
RUN apt-get -y install \
python3-dolfin \
python3-lxml && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Python packages (via pip)
wget \
git \
pkg-config \
build-essential \
# ExaFMM dependencies
libfftw3-dev \
libopenblas-dev \
# Gmsh dependencies
libfltk-gl1.3 \
libfltk-images1.3 \
libfltk1.3 \
libglu1-mesa \
# OpenCL
libpocl-dev \
# Python
python3-dev \
python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN python3 -m pip install --no-cache-dir matplotlib pyopencl numpy scipy numba meshio && \
python3 -m pip install --no-cache-dir flake8 pytest pydocstyle pytest-xdist

# Download Install Gmsh SDK
RUN cd /usr/local && \
Expand All @@ -180,7 +70,7 @@ RUN cd /usr/local && \
ENV PATH=/usr/local/gmsh-${GMSH_VERSION}-Linux64-sdk/bin:$PATH

RUN git clone -b v${EXAFMM_VERSION} https://github.com/exafmm/exafmm-t.git
RUN cd exafmm-t && sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 setup.py install
RUN cd exafmm-t && sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 -m pip install .

# Clear /tmp
RUN rm -rf /tmp/*
Expand All @@ -207,32 +97,32 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -qq update && \
apt-get -yq --with-new-pkgs -o Dpkg::Options::="--force-confold" upgrade && \
apt-get -y install \
libpugixml-dev \
python3-pyopencl \
python3-pybind11 \
libfftw3-dev \
pkg-config \
python-is-python3 \
# OpenCL
libpocl-dev \
# ExaFMM dependencies
libfftw3-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN python3 -m pip install --no-cache-dir matplotlib pyopencl numpy scipy numba meshio && \
python3 -m pip install --no-cache-dir flake8 pytest pydocstyle pytest-xdist

# Install Python packages (via pip)
RUN pip3 install --no-cache-dir meshio>=4.0.16 numpy matplotlib && \
pip3 install --upgrade six
RUN python3 -m pip install --no-cache-dir meshio numpy matplotlib pyopencl

# Install Basix
RUN git clone --depth 1 --branch ${FENICSX_BASIX_TAG} https://github.com/FEniCS/basix.git basix-src && \
cd basix-src && \
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir -S . && \
cmake --build build-dir && \
cmake --install build-dir && \
pip3 install ./python
python3 -m pip install ./python

# Install FEniCSx components
RUN pip3 install --no-cache-dir ipython && \
pip3 install --no-cache-dir git+https://github.com/FEniCS/ufl.git@${FENICSX_UFL_TAG} && \
pip3 install --no-cache-dir git+https://github.com/FEniCS/ffcx.git@${FENICSX_FFCX_TAG}
RUN python3 -m pip install --no-cache-dir ipython && \
python3 -m pip install --no-cache-dir git+https://github.com/FEniCS/ufl.git@${FENICSX_UFL_TAG} && \
python3 -m pip install --no-cache-dir git+https://github.com/FEniCS/ffcx.git@${FENICSX_FFCX_TAG}

# Install FEniCSx
RUN git clone --depth 1 --branch ${FENICSX_DOLFINX_TAG} https://github.com/fenics/dolfinx.git && \
Expand All @@ -243,7 +133,7 @@ RUN git clone --depth 1 --branch ${FENICSX_DOLFINX_TAG} https://github.com/fenic
ninja ${DOLFINX_MAKEFLAGS} install && \
. /usr/local/dolfinx-complex/lib/dolfinx/dolfinx.conf && \
cd ../python && \
PETSC_ARCH=linux-gnu-complex-32 pip3 install --target /usr/local/dolfinx-complex/lib/python3.8/dist-packages --no-dependencies --ignore-installed .
PETSC_ARCH=linux-gnu-complex-32 python3 -m pip install --target /usr/local/dolfinx-complex/lib/python3.8/dist-packages --no-dependencies --ignore-installed .

# complex by default.
ENV LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH \
Expand All @@ -256,7 +146,7 @@ ENV LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH \
RUN wget -nc --quiet https://github.com/exafmm/exafmm-t/archive/v${EXAFMM_VERSION}.tar.gz && \
tar -xf v${EXAFMM_VERSION}.tar.gz && \
cd exafmm-t-${EXAFMM_VERSION} && \
sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 setup.py install
sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 -m pip install .

# Clear /tmp
RUN rm -rf /tmp/*
Expand All @@ -283,31 +173,26 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get -qq update && \
apt-get -yq --with-new-pkgs -o Dpkg::Options::="--force-confold" upgrade && \
apt-get -y install \
python3-pybind11 \
python3-matplotlib \
# ExaFMM dependencies
libfftw3-dev \
pkg-config \
python-is-python3 \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install Python packages (via pip)
RUN pip3 install --no-cache-dir meshio>=4.0.16 "numpy>=1.21,<1.23" && \
pip3 install --upgrade six
RUN python3 -m pip install --no-cache-dir meshio numpy matplotlib

# Install Basix
RUN git clone --depth 1 --branch ${FENICSX_BASIX_TAG} https://github.com/FEniCS/basix.git basix-src && \
cd basix-src && \
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir -S . && \
cmake --build build-dir && \
cmake --install build-dir && \
pip3 install ./python
python3 -m pip install ./python

# Install FEniCSx components
RUN pip3 install --no-cache-dir ipython && \
pip3 install --no-cache-dir git+https://github.com/FEniCS/ufl.git@${FENICSX_UFL_TAG} && \
pip3 install --no-cache-dir git+https://github.com/FEniCS/ffcx.git@${FENICSX_FFCX_TAG}
RUN python3 -m pip install --no-cache-dir git+https://github.com/FEniCS/ufl.git@${FENICSX_UFL_TAG} && \
python3 -m pip install --no-cache-dir git+https://github.com/FEniCS/ffcx.git@${FENICSX_FFCX_TAG}

# Install FEniCSx
RUN git clone --depth 1 --branch ${FENICSX_DOLFINX_TAG} https://github.com/fenics/dolfinx.git && \
Expand All @@ -318,7 +203,7 @@ RUN git clone --depth 1 --branch ${FENICSX_DOLFINX_TAG} https://github.com/fenic
ninja ${DOLFINX_MAKEFLAGS} install && \
. /usr/local/dolfinx-complex/lib/dolfinx/dolfinx.conf && \
cd ../python && \
PETSC_ARCH=linux-gnu-complex-32 pip3 install --target /usr/local/dolfinx-complex/lib/python3.8/dist-packages --no-dependencies --ignore-installed .
PETSC_ARCH=linux-gnu-complex-32 python3 -m pip install --target /usr/local/dolfinx-complex/lib/python3.8/dist-packages --no-dependencies --ignore-installed .

# complex by default.
ENV LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH \
Expand All @@ -331,7 +216,7 @@ ENV LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH \
RUN wget -nc --quiet https://github.com/exafmm/exafmm-t/archive/v${EXAFMM_VERSION}.tar.gz && \
tar -xf v${EXAFMM_VERSION}.tar.gz && \
cd exafmm-t-${EXAFMM_VERSION} && \
sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 setup.py install
sed -i 's/march=native/march=ivybridge/g' ./setup.py && python3 -m pip install .

# Clear /tmp
RUN rm -rf /tmp/*
Expand All @@ -345,21 +230,7 @@ LABEL description="Bempp-cl environment with FEniCSx"

WORKDIR /tmp
RUN git clone https://github.com/bempp/bempp-cl
RUN cd bempp-cl && python3 setup.py install

# Clear /tmp
RUN rm -rf /tmp/*

WORKDIR /root

########################################

FROM bempp-dev-env-with-dolfin as with-dolfin
LABEL description="Bempp-cl environment with FEniCS"

WORKDIR /tmp
RUN git clone https://github.com/bempp/bempp-cl
RUN cd bempp-cl && python3 setup.py install
RUN cd bempp-cl && python3 -m pip install .

# Clear /tmp
RUN rm -rf /tmp/*
Expand All @@ -373,7 +244,7 @@ LABEL description="Bempp Jupyter Lab"

WORKDIR /tmp
RUN git clone https://github.com/bempp/bempp-cl
RUN cd bempp-cl && python3 setup.py install
RUN cd bempp-cl && python3 -m pip install .
RUN cp -r bempp-cl/notebooks /root/example_notebooks
RUN rm /root/example_notebooks/conftest.py /root/example_notebooks/test_notebooks.py

Expand All @@ -385,7 +256,7 @@ WORKDIR /root
ARG TINI_VERSION
ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
RUN chmod +x /tini && \
pip3 install --no-cache-dir jupyter jupyterlab plotly
python3 -m pip install --no-cache-dir jupyter jupyterlab plotly
EXPOSE 8888/tcp

ENTRYPOINT ["/tini", "--", "jupyter", "lab", "--ip", "0.0.0.0", "--no-browser", "--allow-root"]
Expand All @@ -397,31 +268,7 @@ LABEL description="Bempp Jupyter Lab (Numba only)"

WORKDIR /tmp
RUN git clone https://github.com/bempp/bempp-cl
RUN cd bempp-cl && python3 setup.py install
RUN cp -r bempp-cl/notebooks /root/example_notebooks
RUN rm /root/example_notebooks/conftest.py /root/example_notebooks/test_notebooks.py

# Clear /tmp
RUN rm -rf /tmp/*

WORKDIR /root

ARG TINI_VERSION
ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
RUN chmod +x /tini && \
pip3 install --no-cache-dir jupyter jupyterlab plotly
EXPOSE 8888/tcp

ENTRYPOINT ["/tini", "--", "jupyter", "lab", "--ip", "0.0.0.0", "--no-browser", "--allow-root"]

########################################

FROM bempp-dev-env-with-dolfin as fenics-lab
LABEL description="Bempp Jupyter Lab with legacy FEniCS"

WORKDIR /tmp
RUN git clone https://github.com/bempp/bempp-cl
RUN cd bempp-cl && pip3 install .
RUN cd bempp-cl && python3 -m pip install .
RUN cp -r bempp-cl/notebooks /root/example_notebooks
RUN rm /root/example_notebooks/conftest.py /root/example_notebooks/test_notebooks.py

Expand All @@ -433,7 +280,7 @@ WORKDIR /root
ARG TINI_VERSION
ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
RUN chmod +x /tini && \
pip3 install --no-cache-dir jupyter jupyterlab plotly
python3 -m pip install --no-cache-dir jupyter jupyterlab plotly
EXPOSE 8888/tcp

ENTRYPOINT ["/tini", "--", "jupyter", "lab", "--ip", "0.0.0.0", "--no-browser", "--allow-root"]
4 changes: 2 additions & 2 deletions bempp/api/assembly/blocked_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def __init__(self, m, n):
"""Construct an (m x n) blocked boundary operator."""
super().__init__()

self._operators = _np.empty((m, n), dtype=_np.object)
self._operators = _np.empty((m, n), dtype=object)
self._rows = m * [False]
self._cols = n * [False]

Expand Down Expand Up @@ -592,7 +592,7 @@ def __init__(self, ops):

self._ndims = (rows, cols)

self._operators = _np.empty((rows, cols), dtype=_np.object)
self._operators = _np.empty((rows, cols), dtype=object)
self._rows = -_np.ones(rows, dtype=int)
self._cols = -_np.ones(cols, dtype=int)

Expand Down
2 changes: 1 addition & 1 deletion bempp/api/utils/remote_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def __init__(self, ops):

self._ndims = (rows, cols)

self._operators = _np.empty((rows, cols), dtype=_np.object)
self._operators = _np.empty((rows, cols), dtype=object)
self._tags = _np.empty((rows, cols), dtype=_np.int)
self._rows = -_np.ones(rows, dtype=int)
self._cols = -_np.ones(cols, dtype=int)
Expand Down