Skip to content

Commit 2e6c705

Browse files
authored
Merge pull request #2532 from devitocodes/cpu-base
docker: add option to install gcc 14
2 parents 5a6d48e + a84d5cc commit 2e6c705

8 files changed

Lines changed: 116 additions & 124 deletions

File tree

.github/workflows/docker-bases.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,40 @@ on:
1313
- '/docker/Dockerfile.intel'
1414
workflow_dispatch:
1515
inputs:
16+
cpu:
17+
type: boolean
18+
default: false
19+
nvidia:
20+
type: boolean
21+
default: false
22+
amd:
23+
type: boolean
24+
default: false
25+
intel:
26+
type: boolean
27+
default: false
28+
1629
tags:
1730
description: 'Build compiler bases'
1831
schedule:
19-
# Run once a week
20-
- cron: "0 13 * * 1"
32+
# Run once a month
33+
- cron: "0 0 1 * *"
2134

2235
jobs:
2336
#######################################################
2437
############## Basic gcc CPU ##########################
2538
#######################################################
2639
deploy-cpu-bases:
40+
if: inputs.cpu
2741
name: "cpu-base"
2842
runs-on: ubuntu-latest
2943
env:
3044
DOCKER_BUILDKIT: "1"
3145

46+
strategy:
47+
matrix:
48+
gcc: ["", "14"]
49+
3250
steps:
3351
- name: Checkout devito
3452
uses: actions/checkout@v4
@@ -57,15 +75,15 @@ jobs:
5775
context: .
5876
file: './docker/Dockerfile.cpu'
5977
push: true
60-
target: 'gcc'
61-
build-args: 'arch=gcc'
62-
tags: 'devitocodes/bases:cpu-gcc'
78+
build-args: 'gcc=${{ matrix.gcc }}'
79+
tags: 'devitocodes/bases:cpu-gcc${{ matrix.gcc }}'
6380

6481

6582
#######################################################
6683
############## Intel OneApi CPU #######################
6784
#######################################################
6885
deploy-oneapi-bases:
86+
if: inputs.intel
6987
name: "oneapi-base"
7088
runs-on: ubuntu-latest
7189
env:
@@ -127,6 +145,7 @@ jobs:
127145
################### Nvidia nvhpc ######################
128146
#######################################################
129147
deploy-nvidia-bases:
148+
if: inputs.nvidia
130149
name: "nvidia-bases"
131150
runs-on: ["self-hosted", "nvidiagpu"]
132151
env:
@@ -188,6 +207,7 @@ jobs:
188207
##################### AMD #############################
189208
#######################################################
190209
deploy-amd-bases:
210+
if: inputs.amd
191211
name: "amd-base"
192212
runs-on: ["self-hosted", "amdgpu"]
193213
env:

.github/workflows/tutorials.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: Build docker image
7171
if: "contains(matrix.name, 'docker')"
7272
run: |
73-
docker build . --file docker/Dockerfile.devito --tag devito_img
73+
docker build . --pull --file docker/Dockerfile.devito --tag devito_img
7474
7575
- name: Set run prefix
7676
run: |

docker/Dockerfile.amd

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
ARG ROCM_VERSION=6.3.2
77

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

1010
ARG UCX_BRANCH="v1.16.0"
1111
ARG OMPI_BRANCH="v5.0.x"
@@ -14,34 +14,12 @@ ARG OMPI_BRANCH="v5.0.x"
1414
RUN rm /etc/apt/sources.list.d/* \
1515
&& apt-get update \
1616
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
17-
ca-certificates \
18-
git \
19-
ssh \
20-
make \
21-
vim \
22-
nano \
23-
libtinfo* \
24-
initramfs-tools \
25-
libelf-dev \
26-
numactl \
27-
wget \
28-
tmux \
29-
build-essential \
30-
autoconf \
31-
automake \
32-
libtool \
33-
pkg-config \
34-
libnuma* \
35-
gfortran \
36-
flex \
37-
hwloc \
38-
&& apt-get clean
39-
40-
# Requires cmake > 3.22
41-
RUN mkdir -p /opt/cmake \
42-
&& 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
43-
44-
ENV ROCM_HOME=/opt/rocm \
17+
dh-autoreconf python3-venv python3-dev python3-pip git \
18+
ca-certificates ssh make libtinfo* initramfs-tools libelf-dev \
19+
wget build-essential autoconf automake libtool \
20+
pkg-config libnuma* gfortran flex hwloc cmake
21+
22+
ENV ROCM_HOME=/opt/rocm\
4523
UCX_HOME=/opt/ucx \
4624
OMPI_HOME=/opt/ompi
4725

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

55-
# Install tmpi
56-
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi
57-
5833
# Install UCX
5934
RUN cd /tmp/ \
6035
&& git clone --depth 1 https://github.com/openucx/ucx.git -b ${UCX_BRANCH} \
@@ -119,14 +94,6 @@ ENV PATH=$OMPI_HOME/bin:$UCX_HOME/bin:$PATH \
11994
ENV OMPI_ALLOW_RUN_AS_ROOT=1
12095
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
12196

122-
##############################################################
123-
# Additional Devito requirements
124-
##############################################################
125-
126-
# Additional utils and python3
127-
RUN apt-get update && \
128-
apt-get install -y dh-autoreconf python3-venv python3-dev python3-pip
129-
13097
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
13198
rm -rf /var/lib/apt/lists/*
13299

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

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

157124
# MPI env
158125
ENV OMPI_CC="hipcc"

docker/Dockerfile.cpu

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,65 @@
44
# architectures using GCC compilers and OpenMPI.
55
##############################################################
66

7-
ARG OMPI_BRANCH="v4.1.4"
8-
97
# Base image
10-
FROM ubuntu:22.04 as base
8+
FROM ubuntu:22.04 AS base
9+
10+
ARG gcc=""
1111

12-
ENV DEBIAN_FRONTEND noninteractive
12+
ENV DEBIAN_FRONTEND=noninteractive
1313

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

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

23-
# Install tmpi
24-
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi
25-
26-
# Install OpenGL library, necessary for the installation of GemPy
27-
RUN apt-get install -y libgl1-mesa-glx
28-
29-
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
30-
rm -rf /var/lib/apt/lists/*
31-
32-
EXPOSE 8888
33-
CMD ["/bin/bash"]
34-
35-
##############################################################
36-
# GCC standard image
37-
##############################################################
38-
FROM base as gcc
39-
40-
# Install gcc 13 for better hardware and software support
41-
RUN add-apt-repository ppa:ubuntu-toolchain-r/test -y && apt update && \
42-
apt install gcc-13 g++-13 -y && \
43-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \
44-
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100
22+
# Install gcc
23+
RUN if [ -n "$gcc" ]; then \
24+
apt-get install libgmp-dev libmpc-dev libmpfr-dev libisl-dev binutils texinfo -y && \
25+
cd /tmp && mkdir gcc && \
26+
git clone git://gcc.gnu.org/git/gcc.git gcc && \
27+
cd gcc && git checkout releases/gcc-${gcc} && \
28+
mkdir build && cd build && \
29+
../configure --prefix=/opt/gcc-${gcc} --enable-languages=c,c++,fortran --disable-multilib \
30+
--enable-shared --enable-lto --enable-libstdcxx-time=yes --enable-libgomp && \
31+
make -j $(nproc) && make install-strip && \
32+
# Update alternatives
33+
update-alternatives --install /usr/bin/gcc gcc /opt/gcc-${gcc}/bin/gcc 60 && \
34+
update-alternatives --install /usr/bin/g++ g++ /opt/gcc-${gcc}/bin/g++ 60 && \
35+
update-alternatives --install /usr/bin/gfortran gfortran /opt/gcc-${gcc}/bin/gfortran 60 && \
36+
rm -rf /tmp/gcc; \
37+
fi;
4538

46-
ARG OMPI_BRANCH="v4.1.4"
39+
ARG OMPI_BRANCH="v5.0.x"
4740
# Install OpenMPI
48-
RUN mkdir -p /deps && mkdir -p /opt/openmpi && cd /deps && \
41+
RUN cd /tmp && mkdir openmpi && \
4942
git clone --depth 1 --recursive --branch ${OMPI_BRANCH} https://github.com/open-mpi/ompi.git openmpi && \
5043
cd openmpi && ./autogen.pl && \
5144
mkdir build && cd build && \
5245
../configure --prefix=/opt/openmpi/ \
46+
--disable-mpi-fortran \
5347
--enable-mca-no-build=btl-uct --enable-mpi1-compatibility && \
5448
make -j ${nproc} && \
5549
make install && \
56-
cd /deps && rm -rf /deps/openmpi
50+
cd /tmp && rm -rf /tmp/openmpi
5751

5852
# Set OpenMPI path
5953
ENV PATH=${PATH}:/opt/openmpi/bin
60-
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/openmpi/lib
54+
ENV LD_LIBRARY_PATH=/opt/openmpi/lib
55+
56+
# Cleanup
57+
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
58+
59+
EXPOSE 8888
60+
CMD ["/bin/bash"]
61+
62+
##############################################################
63+
# GCC standard image
64+
##############################################################
65+
FROM base AS gcc
6166

6267
# Env vars defaults
6368
ENV DEVITO_ARCH="gcc"

docker/Dockerfile.devito

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,14 @@
55
# Base image with compilers
66
ARG base=devitocodes/bases:cpu-gcc
77

8-
FROM $base as builder
8+
FROM $base AS builder
99

1010
# User/Group Ids
1111
ARG USER_ID=1000
1212
ARG GROUP_ID=1000
1313

1414
################## Install devito ############################################
1515

16-
# Update if outdated and install extras
17-
RUN apt-get update && \
18-
apt-get install -y git cmake libncurses5-dev libncursesw5-dev libdrm-dev libsystemd-dev
19-
20-
# Usefull utilities
21-
# Nvtop
22-
RUN git clone https://github.com/Syllo/nvtop.git /app/nvtop && \
23-
mkdir -p /app/nvtop/build && cd /app/nvtop/build && \
24-
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON && \
25-
make && make install
26-
2716
# Install pip dependencies
2817
RUN python3 -m venv /venv && \
2918
/venv/bin/pip install --no-cache-dir --upgrade pip && \
@@ -43,15 +32,34 @@ RUN eval "$MPI4PY_FLAGS /venv/bin/pip install --no-cache-dir --verbose -r /app/d
4332
# Devito
4433
RUN /venv/bin/pip install --no-cache-dir -e /app/devito[extras,tests] && rm -rf ~/.cache/pip
4534

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

50-
# Last installs (such as gdb needed in user mode) and cleanup
51-
RUN apt-get update && apt install gdb -y && \
52-
apt-get clean && apt-get autoclean && apt-get autoremove -y && \
37+
# tmpi
38+
RUN curl https://raw.githubusercontent.com/Azrael3000/tmpi/master/tmpi -o /usr/local/bin/tmpi
39+
40+
# Update if outdated and install extras
41+
RUN apt-get update && apt-get install -y \
42+
libncurses5-dev libncursesw5-dev libdrm-dev libsystemd-dev \
43+
python3-dbg gdb numactl tmux vim
44+
45+
# Install OpenGL library, necessary for the installation of GemPy
46+
RUN apt-get install -y libgl1-mesa-glx
47+
48+
# Nvtop
49+
RUN export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH && \
50+
git clone https://github.com/Syllo/nvtop.git /app/nvtop && \
51+
mkdir -p /app/nvtop/build && cd /app/nvtop/build && \
52+
cmake .. -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON && \
53+
make && make install
54+
55+
# cleanup
56+
RUN apt-get clean && apt-get autoclean && apt-get autoremove -y && \
5357
rm -rf /var/lib/apt/lists/*
5458

59+
FROM utilities AS user
60+
# COPY is much faster than RUN chown by order of magnitude so we have a final step that
61+
# just copies the built image into the user.
62+
5563
# User/Group Ids
5664
ARG USER_ID=1000
5765
ARG GROUP_ID=1000
@@ -70,6 +78,7 @@ RUN groupadd -g ${GROUP_ID} app && \
7078
chown -R app:app $APP_HOME
7179

7280
COPY --from=builder --chown=app:app /app /app
81+
COPY --from=utilities --chown=app:app /app/nvtop /app/nvtop
7382

7483
ADD --chown=app:app docker/run-jupyter.sh /jupyter
7584
ADD --chown=app:app docker/run-tests.sh /tests

0 commit comments

Comments
 (0)