From 11711a76d20c210e9092ed8d92732499965c5107 Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Sun, 16 Jun 2024 22:13:43 +0200 Subject: [PATCH] BM as the prefix of openmpi and lapack images --- .github/workflows/extract-image-names.sh | 20 ++++-- .github/workflows/main.yml | 4 +- .github/workflows/publish.yml | 4 +- .github/workflows/test.yml | 8 --- README.md | 1 + bm-lapack/Dockerfile | 18 +++++ bm-openmpi/Dockerfile | 18 +++++ bm/Dockerfile | 19 ++++++ build.json | 3 + docker-bake.hcl | 43 +++++++++--- mpich/Dockerfile | 22 ------ openmpi/Dockerfile | 87 ------------------------ 12 files changed, 108 insertions(+), 139 deletions(-) create mode 100644 bm-lapack/Dockerfile create mode 100644 bm-openmpi/Dockerfile create mode 100644 bm/Dockerfile delete mode 100644 mpich/Dockerfile delete mode 100644 openmpi/Dockerfile diff --git a/.github/workflows/extract-image-names.sh b/.github/workflows/extract-image-names.sh index a71b6c1..858e45a 100755 --- a/.github/workflows/extract-image-names.sh +++ b/.github/workflows/extract-image-names.sh @@ -9,31 +9,37 @@ set -euo pipefail # The input to this script is a JSON string passed via BAKE_METADATA env variable # Here's example input (trimmed to relevant bits): # BAKE_METADATA: { -# "qc-base": { +# "bm": { # "containerimage.descriptor": { # "mediaType": "application/vnd.docker.distribution.manifest.v2+json", # "digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", # "size": 6170, # }, # "containerimage.digest": "sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "image.name": "ghcr.io/containers4hpc/qc-base" +# "image.name": "ghcr.io/cnts4sci/bm" # }, -# "qc-full-stack": { -# "image.name": "ghcr.io/containers4hpc/qc-full-stack" +# "bm-openmpi": { +# "image.name": "ghcr.io/cnts4sci/bm-openmpi" # "containerimage.digest": "sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", # "...": "" +# }, +# "bm-lapack": { +# "image.name": "ghcr.io/cnts4sci/bm-lapack" +# "containerimage.digest": "sha256:778a87878eu601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "...": "" # } # } # # Example output (real output is on one line): # # images={ -# "QC_BASE_IMAGE": "ghcr.io/containers4hpc/base@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", -# "QC_FULL_STACK_IMAGE": "ghcr.io/containers4hpc/full-stack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "BM_IMAGE": "ghcr.io/cnts4sci/bm@sha256:8e57a52b924b67567314b8ed3c968859cad99ea13521e60bbef40457e16f391d", +# "BM_OPENMPI_IMAGE": "ghcr.io/cnts4sci/bm-openmpi@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", +# "BM_LAPACK_IMAGE": "ghcr.io/cnts4sci/bm-lapack@sha256:85ee91f61be1ea601591c785db038e5899d68d5fb89e07d66d9efbe8f352ee48", # } # # This json output is later turned to environment variables using fromJson() GHA builtin -# (e.g. BASE_IMAGE=ghcr.io/containers4hpc/base@sha256:8e57a52b...) +# (e.g. BASE_IMAGE=ghcr.io/cnts4sci/base@sha256:8e57a52b...) # and these are in turn read in the docker-compose..yml files for tests. if [[ -z ${BAKE_METADATA-} ]];then diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d41636..ded91ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["qc-base", "qc-full-stack"] + target: ["bm", "bm-openmpi", "bm-lapack"] uses: ./.github/workflows/test.yml with: runsOn: ubuntu-22.04 @@ -56,7 +56,7 @@ jobs: # and only for full-stack image (same for integration tests below). test-arm64: if: >- - github.repository == 'containers4hpc/quantum-container' + github.repository == 'cnts4sci/build-machine' && (github.ref_type == 'tag' || github.ref_name == 'main') needs: build uses: ./.github/workflows/test.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b021012..9b64831 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -29,7 +29,7 @@ jobs: strategy: fail-fast: true matrix: - target: ["qc-base", "qc-full-stack"] + target: ["bm", "bm-openmpi", "bm-lapack"] steps: - uses: actions/checkout@v4 @@ -60,7 +60,7 @@ jobs: uses: docker/metadata-action@v5 env: ${{ fromJSON(steps.build_vars.outputs.vars) }} with: - # e.g. ghcr.io/containers4hpc/qc-full-stack + # e.g. ghcr.io/cnts4sci/bm # type=raw,value=python-${{ env.PYTHON_VERSION }},enable=${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} images: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ matrix.target }} tags: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2b424a..06f01dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,11 +40,3 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Install dependencies 📦 - run: | - pip install -r requirements.txt - pip freeze - - # - name: Run tests - # run: pytest -m "${{ inputs.integration && 'integration' || 'not integration' }}" --target ${{inputs.target}} - # env: ${{ fromJSON(inputs.images) }} diff --git a/README.md b/README.md index 24a3314..70fedb6 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,4 @@ In the image, we provide as much as possible the regular math libraries as we ca - Libxc - ..?? +## Document on where to find which libraries *TODO diff --git a/bm-lapack/Dockerfile b/bm-lapack/Dockerfile new file mode 100644 index 0000000..045d45a --- /dev/null +++ b/bm-lapack/Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:1 + +# Compile Lapack +FROM base-image AS lapack-builder + +WORKDIR /lapack-build +ARG LAPACK_VERSION + +RUN wget -c -O lapack.tar.gz https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${LAPACK_VERSION}.tar.gz && \ + mkdir -p lapack && \ + tar xf lapack.tar.gz -C lapack --strip-components=1 && \ + cd lapack && \ + cp INSTALL/make.inc.gfortran make.inc && \ + make lapacklib blaslib && \ + mkdir -p /usr/local/lapack/lib && \ + cp *.a /usr/local/lapack/lib && \ + rm -rf /lapack-build + diff --git a/bm-openmpi/Dockerfile b/bm-openmpi/Dockerfile new file mode 100644 index 0000000..c9e5556 --- /dev/null +++ b/bm-openmpi/Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:1 + +# Compile openMPI +FROM base-image AS openmpi-builder + +WORKDIR /openmpi-build +ARG OPENMPI_VERSION + +# TODO: v4.1 -< OPENMPI_MAJOR_MINOR_VERSION +RUN wget -c -O openmpi.tar.gz https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-${OPENMPI_VERSION}.tar.gz && \ + mkdir -p openmpi && \ + tar xf openmpi.tar.gz -C openmpi --strip-components=1 && \ + cd openmpi && \ + ./configure --prefix=/opt/openmpi --enable-static --disable-shared && \ + make -j$(nproc) && \ + make install && \ + rm -rf /openmpi-build + diff --git a/bm/Dockerfile b/bm/Dockerfile new file mode 100644 index 0000000..9aa4b1d --- /dev/null +++ b/bm/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 +FROM base-image + +# Build toolchains +RUN apt-get update && apt-get install -y \ + build-essential \ + wget \ + curl \ + gcc \ + g++ \ + make \ + libtool \ + autoconf \ + automake \ + gfortran \ + bzip2 \ + tar \ + git && \ + rm -rf /var/lib/apt/lists/* diff --git a/build.json b/build.json index 5b5634d..92dfb21 100644 --- a/build.json +++ b/build.json @@ -2,6 +2,9 @@ "variable": { "OPENMPI_VERSION": { "default": "4.1.6" + }, + "LAPACK_VERSION": { + "default": "3.10.1" } } } diff --git a/docker-bake.hcl b/docker-bake.hcl index 38b8122..02f8cba 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -14,20 +14,19 @@ variable "PLATFORMS" { default = ["linux/amd64"] } -variable "BASE_IMAGE" { - default = "ubuntu:20.04" -} - -variable "RUNTIME_BASE_IMAGE" { +variable "SYSTEM_BASE_IMAGE" { default = "ubuntu:20.04" } variable "TARGETS" { - default = ["openmpi"] + default = ["bm", "bm-openmpi", "bm-lapack"] } # TAGS for softwares variable "OPENMPI_VERSION" { + +} +variable "LAPACK_VERSION" { } function "tags" { @@ -41,14 +40,36 @@ group "default" { targets = "${TARGETS}" } -target "openmpi" { - tags = tags("openmpi") - context = "openmpi" +target "bm" { + tags = tags("bm") + context = "bm" + contexts = { + base-image = "docker-image://${SYSTEM_BASE_IMAGE}" + } + platforms = "${PLATFORMS}" +} + +target "bm-openmpi" { + tags = tags("bm-openmpi") + context = "bm-openmpi" + contexts = { + base-image = "target:bm" + } platforms = "${PLATFORMS}" args = { - BASE_IMAGE = "${BASE_IMAGE}" - RUNTIME_BASE_IMAGE = "${RUNTIME_BASE_IMAGE}" OPENMPI_VERSION = "${OPENMPI_VERSION}" } } +target "bm-lapack" { + tags = tags("bm-lapack") + context = "bm-lapack" + contexts = { + base-image = "target:bm" + } + platforms = "${PLATFORMS}" + args = { + LAPACK_VERSION = "${LAPACK_VERSION}" + } +} + diff --git a/mpich/Dockerfile b/mpich/Dockerfile deleted file mode 100644 index f9d0488..0000000 --- a/mpich/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM ethcscs/mpich:ub1804_cuda92_mpi314 - -## Uncomment the following lines if you want to build mpi yourself: -RUN apt-get update \ -&& apt-get install -y --no-install-recommends \ - wget \ - gfortran \ - gcc \ - g++ \ - zlib1g-dev \ - libopenblas-dev \ -&& rm -rf /var/lib/apt/lists/* - -# Install MPICH -RUN wget -q http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz \ -&& tar xf mpich-3.1.4.tar.gz \ -&& cd mpich-3.1.4 \ -&& ./configure --enable-fortran --enable-fast=all,O3 --prefix=/usr \ -&& make -j$(nproc) \ -&& make install \ -&& ldconfig \ -&& rm -rf ../mpich-3.1.4 diff --git a/openmpi/Dockerfile b/openmpi/Dockerfile deleted file mode 100644 index 1152368..0000000 --- a/openmpi/Dockerfile +++ /dev/null @@ -1,87 +0,0 @@ -# syntax=docker/dockerfile:1 - -ARG BASE_IMAGE -ARG RUNTIME_BASE_IMAGE - -FROM ${BASE_IMAGE} AS toolchain-builder - -WORKDIR /openmpi-build - -# Build toolchains -RUN apt-get update && apt-get install -y \ - build-essential \ - wget \ - curl \ - gcc \ - g++ \ - make \ - libtool \ - autoconf \ - automake \ - gfortran \ - bzip2 \ - tar \ - git && \ - rm -rf /var/lib/apt/lists/* - -RUN wget -c -O openmpi.tar.gz https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.6.tar.gz && \ - mkdir -p openmpi && \ - tar xf openmpi.tar.gz -C openmpi --strip-components=1 && \ - cd openmpi && \ - ./configure --prefix=/opt/openmpi --enable-static --disable-shared && \ - make -j$(nproc) && \ - make install - -# Compile Lapack -WORKDIR /lapack-build -ARG LAPACK_VERSION="3.10.1" - -RUN wget -c -O lapack.tar.gz https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v${LAPACK_VERSION}.tar.gz && \ - mkdir -p lapack && \ - tar xf lapack.tar.gz -C lapack --strip-components=1 && \ - cd lapack && \ - cp INSTALL/make.inc.gfortran make.inc && \ - make lapacklib blaslib && \ - mkdir -p /usr/local/lapack/lib && \ - cp *.a /usr/local/lapack/lib - -# As build-machine image, it is not actually a runtime -# but I do the runtime multi-stage build to minimize the size -# and for testing the integrity of the openmpi/lapack... static build and move -FROM ${RUNTIME_BASE_IMAGE} - -# Copy build toolchains from the builder stage -COPY --from=toolchain-builder /opt/openmpi /opt/openmpi -COPY --from=toolchain-builder /usr/local/lapack /usr/local/lapack - -RUN apt-get update && apt-get install -y \ - build-essential \ - wget \ - curl \ - gcc \ - g++ \ - make \ - libtool \ - autoconf \ - automake \ - gfortran \ - bzip2 \ - tar \ - git && \ - rm -rf /var/lib/apt/lists/* - -# Set up environment variables for OpenMPI -ENV PATH="/opt/openmpi/bin:$PATH" -ENV LD_LIBRARY_PATH="/opt/openmpi/lib:$LD_LIBRARY_PATH" - -# Compile QE (for test only) -ARG QE_VERSION="7.0" - -RUN wget -c -O qe.tar.gz https://gitlab.com/QEF/q-e/-/archive/qe-${QE_VERSION}/q-e-qe-${QE_VERSION}.tar.gz && \ - mkdir -p qe && \ - tar xf qe.tar.gz -C qe --strip-components=1 && \ - cd qe && \ - LAPACK_LIBS=/usr/local/lapack/lib/liblapack.a BLAS_LIBS=/usr/local/lapack/lib/librefblas.a ./configure -enable-static && \ - make -j8 pw && \ - make install -