From cb3bd984d9abd644597f5609b182e38f335207c8 Mon Sep 17 00:00:00 2001 From: Boian Petkantchin Date: Mon, 13 May 2024 17:39:05 -0700 Subject: [PATCH] Install OpenMPI and mpi4py in AMD Ubuntu images (#8) Refactor the other commands to cleanup after each docker step to avoid growing the final layer with unused stuff. --- build_tools/install_amdgpu.sh | 2 ++ build_tools/install_base.sh | 20 ++++++++++++++++++ build_tools/install_openmpi.sh | 17 +++++++++++++++ build_tools/install_the_rock.sh | 4 +++- .../amdgpu_ubuntu_jammy_ghr_x86_64.Dockerfile | 17 +++++++-------- .../amdgpu_ubuntu_jammy_x86_64.Dockerfile | 21 ++++++++++--------- 6 files changed, 61 insertions(+), 20 deletions(-) create mode 100755 build_tools/install_base.sh create mode 100755 build_tools/install_openmpi.sh diff --git a/build_tools/install_amdgpu.sh b/build_tools/install_amdgpu.sh index 89411d6..857516a 100755 --- a/build_tools/install_amdgpu.sh +++ b/build_tools/install_amdgpu.sh @@ -28,3 +28,5 @@ fi wget https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2023.Q3.1/amdvlk_2023.Q3.1_amd64.deb && \ dpkg -i amdvlk_2023.Q3.1_amd64.deb + +apt clean && rm -rf /var/lib/apt/lists/* diff --git a/build_tools/install_base.sh b/build_tools/install_base.sh new file mode 100755 index 0000000..a48e74f --- /dev/null +++ b/build_tools/install_base.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright 2024 The IREE Authors +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Basic packages. + +set -euo pipefail + +apt update +apt install -y \ + wget python3.11-dev python3-pip git unzip curl gnupg2 \ + lsb-release vulkan-tools && \ + update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 3 && \ + update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.11 3 + +apt clean && rm -rf /var/lib/apt/lists/* diff --git a/build_tools/install_openmpi.sh b/build_tools/install_openmpi.sh new file mode 100755 index 0000000..a5f4f06 --- /dev/null +++ b/build_tools/install_openmpi.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright 2024 The IREE Authors +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Needed by IREE E2E collectives tests. + +set -euo pipefail + +apt update +apt install -y libopenmpi-dev + +# Needs to run after installing openmpi as it will build against it. +python -m pip install --no-cache-dir mpi4py diff --git a/build_tools/install_the_rock.sh b/build_tools/install_the_rock.sh index 0a371e9..5616b90 100755 --- a/build_tools/install_the_rock.sh +++ b/build_tools/install_the_rock.sh @@ -35,7 +35,7 @@ apt update apt install -y \ repo git-lfs libnuma-dev ninja-build g++ pkg-config libdrm-dev \ libelf-dev xxd libgl1-mesa-dev -python -m pip install CppHeaderParser +python -m pip install --no-cache-dir CppHeaderParser # Make sure git does not report Committer identity unknown errors. # export GIT_COMMITTER_NAME="Noname" @@ -69,3 +69,5 @@ cmake --build build cmake --install build --component amdgpu-runtime cmake --install build --component amdgpu-runtime-dev cmake --install build --component amdgpu-compiler + +apt clean && rm -rf /var/lib/apt/lists/* diff --git a/dockerfiles/amdgpu_ubuntu_jammy_ghr_x86_64.Dockerfile b/dockerfiles/amdgpu_ubuntu_jammy_ghr_x86_64.Dockerfile index 124592f..697ce95 100644 --- a/dockerfiles/amdgpu_ubuntu_jammy_ghr_x86_64.Dockerfile +++ b/dockerfiles/amdgpu_ubuntu_jammy_ghr_x86_64.Dockerfile @@ -4,11 +4,9 @@ FROM docker.io/myoung34/github-runner:2.314.1-ubuntu-jammy # Basic packages. -RUN apt update && \ - apt install -y \ - wget python3.11 python3-pip git unzip curl gnupg2 lsb-release vulkan-tools && \ - update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 3 && \ - update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.11 3 +WORKDIR /install-base +COPY build_tools/install_base.sh ./ +RUN ./install_base.sh "${CMAKE_VERSION}" && rm -rf /install-base # CMake WORKDIR /install-cmake @@ -22,17 +20,18 @@ WORKDIR /install-amdgpu ARG AMDGPU_VERSION=6.1 COPY build_tools/install_amdgpu.sh ./ RUN ./install_amdgpu.sh "${AMDGPU_VERSION}" && rm -rf /install-amdgpu -WORKDIR / # TheRock (ROCm) WORKDIR /install-the-rock COPY build_tools/install_the_rock.sh ./ RUN ./install_the_rock.sh \ && rm -rf /install-the-rock -WORKDIR / -# Clean up. -RUN apt clean && rm -rf /var/lib/apt/lists/* +# OpenMPI +WORKDIR /install-openmpi +COPY build_tools/install_openmpi.sh ./ +RUN ./install_openmpi.sh \ + && rm -rf /install-openmpi # Switch back to the working directory upstream expects. WORKDIR /actions-runner diff --git a/dockerfiles/amdgpu_ubuntu_jammy_x86_64.Dockerfile b/dockerfiles/amdgpu_ubuntu_jammy_x86_64.Dockerfile index 1ec7d1a..2d30837 100644 --- a/dockerfiles/amdgpu_ubuntu_jammy_x86_64.Dockerfile +++ b/dockerfiles/amdgpu_ubuntu_jammy_x86_64.Dockerfile @@ -4,11 +4,9 @@ FROM ubuntu:jammy # Basic packages. -RUN apt update && \ - apt install -y \ - wget python3.11 python3-pip git unzip curl gnupg2 lsb-release vulkan-tools && \ - update-alternatives --install /usr/local/bin/python python /usr/bin/python3.11 3 && \ - update-alternatives --install /usr/local/bin/python3 python3 /usr/bin/python3.11 3 +WORKDIR /install-base +COPY build_tools/install_base.sh ./ +RUN ./install_base.sh "${CMAKE_VERSION}" && rm -rf /install-base # CMake WORKDIR /install-cmake @@ -22,14 +20,17 @@ WORKDIR /install-amdgpu ARG AMDGPU_VERSION=6.1 COPY build_tools/install_amdgpu.sh ./ RUN ./install_amdgpu.sh "${AMDGPU_VERSION}" && rm -rf /install-amdgpu -WORKDIR / # TheRock (ROCm) WORKDIR /install-the-rock COPY build_tools/install_the_rock.sh ./ RUN ./install_the_rock.sh \ -# && rm -rf /install-the-rock -WORKDIR / + && rm -rf /install-the-rock -# Clean up. -RUN apt clean && rm -rf /var/lib/apt/lists/* +# OpenMPI +WORKDIR /install-openmpi +COPY build_tools/install_openmpi.sh ./ +RUN ./install_openmpi.sh \ + && rm -rf /install-openmpi + +WORKDIR /