Skip to content

Commit

Permalink
Add intel-oneapi-compiler into pcluster image (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmsachs authored Oct 4, 2024
1 parent 3147563 commit 8449353
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
33 changes: 25 additions & 8 deletions Dockerfiles/pcluster-amazonlinux-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,23 @@ RUN curl -sOL https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTAL
# Bootstrap spack compiler installation into the eventual installation tree
# Defined in spack/share/spack/gitlab/cloud_pipelines/configs/config.yaml
ARG SPACK_ROOT="/bootstrap-compilers/spack"
# commit after https://github.com/spack/spack/pull/34821
ARG SPACK_COMMIT=f27d012
ARG SPACK_TAG="develop-2024-07-07"
ARG TARGETARCH
COPY Dockerfiles/pcluster-amazonlinux-2/${TARGETARCH}/packages.yaml /root/.spack/packages.yaml
RUN mkdir -p $(dirname "${SPACK_ROOT}") \
&& git clone https://github.com/spack/spack "${SPACK_ROOT}" \
&& pushd "${SPACK_ROOT}" && git checkout ${SPACK_COMMIT} && popd \
&& git clone -b ${SPACK_TAG} https://github.com/spack/spack "${SPACK_ROOT}" \
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "${SPACK_ROOT}/etc/spack/config.yaml" \
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "/bootstrap/cloud_pipelines-config.yaml" \
&& . "${SPACK_ROOT}/share/spack/setup-env.sh" \
&& spack compiler add \
&& spack external find \
&& spack tags build-tools | xargs -I {} spack config rm packages:{} \
&& spack install gcc \
&& spack buildcache create -a -u /bootstrap-gcc-cache $(spack find --format '/{hash}') \
&& rm -rf $(dirname "${SPACK_ROOT}") /root/.spack

# Sign the buildcache
RUN --mount=type=secret,id=bootstrap_gcc_key \
mkdir -p $(dirname "${SPACK_ROOT}") \
&& git clone https://github.com/spack/spack "${SPACK_ROOT}" \
&& pushd "${SPACK_ROOT}" && git checkout ${SPACK_COMMIT} && popd \
&& git clone -b ${SPACK_TAG} https://github.com/spack/spack "${SPACK_ROOT}" \
&& . "${SPACK_ROOT}/share/spack/setup-env.sh" \
&& spack gpg trust /run/secrets/bootstrap_gcc_key \
&& secretkey_fingerprint=$(GNUPGHOME="${SPACK_ROOT}"/opt/spack/gpg gpg2 -K --with-fingerprint --with-colons | awk -F: '/fpr/{print $10}') \
Expand All @@ -141,6 +136,28 @@ RUN --mount=type=secret,id=bootstrap_gcc_key \
&& spack gpg publish --rebuild-index -m bootstrap-gcc-cache ${secretkey_fingerprint} \
&& rm -rf $(dirname "${SPACK_ROOT}") /root/.spack

# Add oneapi compiler into container. The stack can pick up the compilers by using ${SPACK_ROOT}/etc/spack/compilers.yaml
# [email protected] is the last version compatible with AL2 glibc 2.26
COPY Dockerfiles/pcluster-amazonlinux-2/${TARGETARCH}/packages.yaml /root/.spack/packages.yaml
RUN if [[ "amd64" == "${TARGETARCH}" ]]; then mkdir -p $(dirname "${SPACK_ROOT}") \
&& git clone --depth=1 -b ${SPACK_TAG} https://github.com/spack/spack.git "${SPACK_ROOT}" \
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "${SPACK_ROOT}/etc/spack/config.yaml" \
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "/bootstrap/cloud_pipelines-config.yaml" \
&& . "${SPACK_ROOT}/share/spack/setup-env.sh" \
&& spack load gcc \
&& spack compiler add --scope site \
&& cd "${SPACK_ROOT}" \
&& spack install [email protected] \
&& . "$(spack location -i intel-oneapi-compilers)"/setvars.sh \
&& spack compiler add --scope site \
&& rm -rf $(find $(spack find --format '{prefix}' intel-oneapi-compilers) -mindepth 1 -type d -name 'conda_channel') \
&& rm -rf $(find $(spack find --format '{prefix}' intel-oneapi-compilers) -mindepth 1 -type d -name 'debugger') \
&& rm -rf $(find $(spack find --format '{prefix}' intel-oneapi-compilers) -mindepth 1 -type d -name '*32*') \
&& rm -rf $(find $(spack find --format '{prefix}' intel-oneapi-compilers) -mindepth 1 -type d -name 'oclfpga') \
&& rm -rf /opt/intel /tmp/* \
&& spack clean -a \
&& rm -rf /root/.spack ; fi

ENV PATH=/bootstrap/runner/view/bin:$PATH \
NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=compute,utility \
Expand Down
5 changes: 4 additions & 1 deletion Dockerfiles/pcluster-amazonlinux-2/amd64/packages.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
--- # GCC setup for all AMD64 based targets
packages:
gcc:
compiler: [gcc]
require: "gcc@12 +strip +binutils ^[email protected] target=x86_64_v3"
intel-oneapi-compilers:
require: "intel-oneapi-compilers %gcc target=x86_64_v3"
all:
compiler: [gcc]

0 comments on commit 8449353

Please sign in to comment.