Skip to content

Commit

Permalink
Merge pull request #2532 from devitocodes/cpu-base
Browse files Browse the repository at this point in the history
docker: add option to install gcc 14
  • Loading branch information
mloubout authored Feb 13, 2025
2 parents 5a6d48e + a84d5cc commit 2e6c705
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 124 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/docker-bases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@ on:
- '/docker/Dockerfile.intel'
workflow_dispatch:
inputs:
cpu:
type: boolean
default: false
nvidia:
type: boolean
default: false
amd:
type: boolean
default: false
intel:
type: boolean
default: false

tags:
description: 'Build compiler bases'
schedule:
# Run once a week
- cron: "0 13 * * 1"
# Run once a month
- cron: "0 0 1 * *"

jobs:
#######################################################
############## Basic gcc CPU ##########################
#######################################################
deploy-cpu-bases:
if: inputs.cpu
name: "cpu-base"
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"

strategy:
matrix:
gcc: ["", "14"]

steps:
- name: Checkout devito
uses: actions/checkout@v4
Expand Down Expand Up @@ -57,15 +75,15 @@ jobs:
context: .
file: './docker/Dockerfile.cpu'
push: true
target: 'gcc'
build-args: 'arch=gcc'
tags: 'devitocodes/bases:cpu-gcc'
build-args: 'gcc=${{ matrix.gcc }}'
tags: 'devitocodes/bases:cpu-gcc${{ matrix.gcc }}'


#######################################################
############## Intel OneApi CPU #######################
#######################################################
deploy-oneapi-bases:
if: inputs.intel
name: "oneapi-base"
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -127,6 +145,7 @@ jobs:
################### Nvidia nvhpc ######################
#######################################################
deploy-nvidia-bases:
if: inputs.nvidia
name: "nvidia-bases"
runs-on: ["self-hosted", "nvidiagpu"]
env:
Expand Down Expand Up @@ -188,6 +207,7 @@ jobs:
##################### AMD #############################
#######################################################
deploy-amd-bases:
if: inputs.amd
name: "amd-base"
runs-on: ["self-hosted", "amdgpu"]
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Build docker image
if: "contains(matrix.name, 'docker')"
run: |
docker build . --file docker/Dockerfile.devito --tag devito_img
docker build . --pull --file docker/Dockerfile.devito --tag devito_img
- name: Set run prefix
run: |
Expand Down
51 changes: 9 additions & 42 deletions docker/Dockerfile.amd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ARG ROCM_VERSION=6.3.2

FROM rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete as sdk-base
FROM rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete AS sdk-base

ARG UCX_BRANCH="v1.16.0"
ARG OMPI_BRANCH="v5.0.x"
Expand All @@ -14,34 +14,12 @@ ARG OMPI_BRANCH="v5.0.x"
RUN rm /etc/apt/sources.list.d/* \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
git \
ssh \
make \
vim \
nano \
libtinfo* \
initramfs-tools \
libelf-dev \
numactl \
wget \
tmux \
build-essential \
autoconf \
automake \
libtool \
pkg-config \
libnuma* \
gfortran \
flex \
hwloc \
&& apt-get clean

# Requires cmake > 3.22
RUN mkdir -p /opt/cmake \
&& wget --no-check-certificate --quiet -O - https://cmake.org/files/v3.22/cmake-3.22.2-linux-x86_64.tar.gz | tar --strip-components=1 -xz -C /opt/cmake

ENV ROCM_HOME=/opt/rocm \
dh-autoreconf python3-venv python3-dev python3-pip git \
ca-certificates ssh make libtinfo* initramfs-tools libelf-dev \
wget build-essential autoconf automake libtool \
pkg-config libnuma* gfortran flex hwloc cmake

ENV ROCM_HOME=/opt/rocm\
UCX_HOME=/opt/ucx \
OMPI_HOME=/opt/ompi

Expand All @@ -52,9 +30,6 @@ ENV PATH=$ROCM_HOME/bin:$PATH \
# Until rocm base has it fixed
RUN ln -s /opt/rocm/llvm/bin/offload-arch /opt/rocm/bin/offload-arch | echo "offload-arch already exis"

# Install tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi

# Install UCX
RUN cd /tmp/ \
&& git clone --depth 1 https://github.com/openucx/ucx.git -b ${UCX_BRANCH} \
Expand Down Expand Up @@ -119,14 +94,6 @@ ENV PATH=$OMPI_HOME/bin:$UCX_HOME/bin:$PATH \
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1

##############################################################
# Additional Devito requirements
##############################################################

# Additional utils and python3
RUN apt-get update && \
apt-get install -y dh-autoreconf python3-venv python3-dev python3-pip

RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -137,7 +104,7 @@ CMD ["/bin/bash"]
# AOMP for GPUs (OpenMP offloading)
########################################################################
# This will only trigger if arch is aomp since the final stage depends on it
FROM sdk-base as amdclang
FROM sdk-base AS amdclang

# MPI env
ENV OMPI_CC="amdclang"
Expand All @@ -152,7 +119,7 @@ ENV DEVITO_LANGUAGE="openmp"
# HIPCC for GPUs (HIP)
########################################################################
# This will only trigger if arch is hip since the final stage depends on it
FROM sdk-base as hip
FROM sdk-base AS hip

# MPI env
ENV OMPI_CC="hipcc"
Expand Down
71 changes: 38 additions & 33 deletions docker/Dockerfile.cpu
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,65 @@
# architectures using GCC compilers and OpenMPI.
##############################################################

ARG OMPI_BRANCH="v4.1.4"

# Base image
FROM ubuntu:22.04 as base
FROM ubuntu:22.04 AS base

ARG gcc=""

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

# Install python
RUN apt-get update && \
apt-get install -y dh-autoreconf python3-venv python3-dev python3-pip
apt-get install -y software-properties-common dh-autoreconf python3-venv python3-dev python3-pip

# Install for basic base not containing it
RUN apt-get install -y vim wget git flex libnuma-dev tmux \
numactl hwloc curl \
RUN apt-get install -y wget flex libnuma-dev hwloc curl cmake git \
autoconf libtool build-essential procps software-properties-common

# Install tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi

# Install OpenGL library, necessary for the installation of GemPy
RUN apt-get install -y libgl1-mesa-glx

RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

EXPOSE 8888
CMD ["/bin/bash"]

##############################################################
# GCC standard image
##############################################################
FROM base as gcc

# Install gcc 13 for better hardware and software support
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && apt update && \
apt install gcc-13 g++-13 -y && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100
# Install gcc
RUN if [ -n "$gcc" ]; then \
apt-get install libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils texinfo -y && \
cd /tmp && mkdir gcc && \
git clone git://gcc.gnu.org/git/gcc.git gcc && \
cd gcc && git checkout releases/gcc-${gcc} && \
mkdir build && cd build && \
../configure --prefix=/opt/gcc-${gcc} --enable-languages=c,c++,fortran --disable-multilib \
--enable-shared --enable-lto --enable-libstdcxx-time=yes --enable-libgomp && \
make -j $(nproc) && make install-strip && \
# Update alternatives
update-alternatives --install /usr/bin/gcc gcc /opt/gcc-${gcc}/bin/gcc 60 && \
update-alternatives --install /usr/bin/g++ g++ /opt/gcc-${gcc}/bin/g++ 60 && \
update-alternatives --install /usr/bin/gfortran gfortran /opt/gcc-${gcc}/bin/gfortran 60 && \
rm -rf /tmp/gcc; \
fi;

ARG OMPI_BRANCH="v4.1.4"
ARG OMPI_BRANCH="v5.0.x"
# Install OpenMPI
RUN mkdir -p /deps && mkdir -p /opt/openmpi && cd /deps && \
RUN cd /tmp && mkdir openmpi && \
git clone --depth 1 --recursive --branch ${OMPI_BRANCH} https://github.com/open-mpi/ompi.git openmpi && \
cd openmpi && ./autogen.pl && \
mkdir build && cd build && \
../configure --prefix=/opt/openmpi/ \
--disable-mpi-fortran \
--enable-mca-no-build=btl-uct --enable-mpi1-compatibility && \
make -j ${nproc} && \
make install && \
cd /deps && rm -rf /deps/openmpi
cd /tmp && rm -rf /tmp/openmpi

# Set OpenMPI path
ENV PATH=${PATH}:/opt/openmpi/bin
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/openmpi/lib
ENV LD_LIBRARY_PATH=/opt/openmpi/lib

# Cleanup
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

EXPOSE 8888
CMD ["/bin/bash"]

##############################################################
# GCC standard image
##############################################################
FROM base AS gcc

# Env vars defaults
ENV DEVITO_ARCH="gcc"
Expand Down
45 changes: 27 additions & 18 deletions docker/Dockerfile.devito
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,14 @@
# Base image with compilers
ARG base=devitocodes/bases:cpu-gcc

FROM $base as builder
FROM $base AS builder

# User/Group Ids
ARG USER_ID=1000
ARG GROUP_ID=1000

################## Install devito ############################################

# Update if outdated and install extras
RUN apt-get update && \
apt-get install -y git cmake libncurses5-dev libncursesw5-dev libdrm-dev libsystemd-dev

# Usefull utilities
# Nvtop
RUN git clone https://github.com/Syllo/nvtop.git /app/nvtop && \
mkdir -p /app/nvtop/build && cd /app/nvtop/build && \
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON && \
make && make install

# Install pip dependencies
RUN python3 -m venv /venv && \
/venv/bin/pip install --no-cache-dir --upgrade pip && \
Expand All @@ -43,15 +32,34 @@ RUN eval "$MPI4PY_FLAGS /venv/bin/pip install --no-cache-dir --verbose -r /app/d
# Devito
RUN /venv/bin/pip install --no-cache-dir -e /app/devito[extras,tests] && rm -rf ~/.cache/pip

FROM $base as user
# COPY is much faster than RUN chown by order of magnitude so we have a final step that
# just copies the built image into the user.
FROM $base AS utilities

# Last installs (such as gdb needed in user mode) and cleanup
RUN apt-get update && apt install gdb -y && \
apt-get clean && apt-get autoclean && apt-get autoremove -y && \
# tmpi
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi

# Update if outdated and install extras
RUN apt-get update && apt-get install -y \
libncurses5-dev libncursesw5-dev libdrm-dev libsystemd-dev \
python3-dbg gdb numactl tmux vim

# Install OpenGL library, necessary for the installation of GemPy
RUN apt-get install -y libgl1-mesa-glx

# Nvtop
RUN export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH && \
git clone https://github.com/Syllo/nvtop.git /app/nvtop && \
mkdir -p /app/nvtop/build && cd /app/nvtop/build && \
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON && \
make && make install

# cleanup
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*

FROM utilities AS user
# COPY is much faster than RUN chown by order of magnitude so we have a final step that
# just copies the built image into the user.

# User/Group Ids
ARG USER_ID=1000
ARG GROUP_ID=1000
Expand All @@ -70,6 +78,7 @@ RUN groupadd -g ${GROUP_ID} app && \
chown -R app:app $APP_HOME

COPY --from=builder --chown=app:app /app /app
COPY --from=utilities --chown=app:app /app/nvtop /app/nvtop

ADD --chown=app:app docker/run-jupyter.sh /jupyter
ADD --chown=app:app docker/run-tests.sh /tests
Expand Down
Loading

0 comments on commit 2e6c705

Please sign in to comment.