Skip to content

Commit

Permalink
Re-designed all the Ubuntu 20.04 based "GPU images". (#99)
Browse files Browse the repository at this point in the history
They are now all based on the "latest" vanilla Ubuntu 20.04 image,
just adding GPU SDKs on top. From DEB repositories in all cases.
  • Loading branch information
krasznaa authored May 27, 2024
1 parent 74b7b96 commit df7a9c0
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 692 deletions.
223 changes: 29 additions & 194 deletions ubuntu2004_cuda/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,198 +1,33 @@
FROM nvidia/cuda:11.6.2-devel-ubuntu20.04

LABEL description="Ubuntu 20.04 with Acts dependencies and CUDA"
LABEL maintainer="Paul Gessinger <[email protected]"
# increase whenever any of the RUN commands change
LABEL version="1"

# DEBIAN_FRONTEND ensures non-blocking operation (tzdata is a problem)
ENV DEBIAN_FRONTEND noninteractive

# install dependencies from the package manager.
# Docker machinery, part of the ACTS project
#
# see also https://root.cern.ch/build-prerequisites
RUN apt-get update -y \
&& apt-get install -y \
build-essential \
curl \
git \
freeglut3-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-test-dev \
libexpat-dev \
libeigen3-dev \
libftgl-dev \
libgl2ps-dev \
libglew-dev \
libgsl-dev \
liblz4-dev \
liblzma-dev \
libpcre3-dev \
libtbb-dev \
libx11-dev \
libxext-dev \
libxft-dev \
libxpm-dev \
libxerces-c-dev \
libzstd-dev \
ninja-build \
python3 \
python3-dev \
python3-pip \
rsync \
zlib1g-dev \
ccache \
&& apt-get clean -y

# manual builds for hep-specific packages
ENV GET curl --location --silent --create-dirs
ENV UNPACK_TO_SRC tar -xz --strip-components=1 --directory src
ENV PREFIX /usr/local

# CMake 3.16.3 version in APT is too old
# requires rsync; installation uses `rsync` instead of `install`
RUN mkdir src \
&& ${GET} https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2-Linux-x86_64.tar.gz \
| ${UNPACK_TO_SRC} \
&& rsync -ruv src/ ${PREFIX} \
&& cd .. \
&& rm -rf src

# Geant4
RUN mkdir src \
&& ${GET} https://geant4-data.web.cern.ch/geant4-data/releases/geant4.10.06.p01.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DGEANT4_BUILD_CXXSTD=17 \
-DGEANT4_INSTALL_DATA=OFF \
-DGEANT4_USE_GDML=ON \
-DGEANT4_USE_SYSTEM_EXPAT=ON \
-DGEANT4_USE_SYSTEM_ZLIB=ON \
&& cmake --build build -- install \
&& rm -rf build src

# HepMC3
RUN mkdir src \
&& ${GET} https://hepmc.web.cern.ch/hepmc/releases/HepMC3-3.2.1.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DHEPMC3_BUILD_STATIC_LIBS=OFF \
-DHEPMC3_ENABLE_PYTHON=OFF \
-DHEPMC3_ENABLE_ROOTIO=OFF \
-DHEPMC3_ENABLE_SEARCH=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# Pythia8
# requires rsync; installation uses `rsync` instead of `install`
RUN mkdir src \
&& ${GET} https://pythia.org/download/pythia82/pythia8244.tgz \
| ${UNPACK_TO_SRC} \
&& cd src \
&& ./configure --enable-shared --prefix=${PREFIX} \
&& make -j$(nproc) install \
&& cd .. \
&& rm -rf src

# xxHash
RUN mkdir src \
&& ${GET} https://github.com/Cyan4973/xxHash/archive/v0.7.3.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src/cmake_unofficial -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
&& cmake --build build -- install \
&& rm -rf build src

# nlohmann's JSON
RUN mkdir src \
&& ${GET} https://github.com/nlohmann/json/archive/refs/tags/v3.10.2.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DJSON_BuildTests=OFF \
&& cmake --build build -- install \
&& rm -rf build src

# ROOT
RUN mkdir src \
&& ${GET} https://root.cern/download/root_v6.24.06.source.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-Dfail-on-missing=ON \
-Dgminimal=ON \
-Dgdml=ON \
-Dopengl=ON \
-Dpyroot=ON \
&& cmake --build build -- install \
&& rm -rf build src

# environment variables needed to find ROOT libraries
ENV LD_LIBRARY_PATH /usr/local/lib
ENV PYTHON_PATH /usr/local/lib

# podio
RUN mkdir src \
&& ${GET} https://github.com/AIDASoft/podio/archive/refs/tags/v00-14-01.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DBUILD_TESTING=OFF \
-USE_EXTERNAL_CATCH2=OFF \
&& cmake --build build -- install \
&& rm -rf build src
# (c) 2021-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# EDM4hep
RUN pip3 install jinja2 pyyaml \
&& mkdir src \
&& ${GET} https://github.com/key4hep/EDM4hep/archive/refs/tags/v00-04-02.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DBUILD_TESTING=OFF \
-DUSE_EXTERNAL_CATCH2=OFF \
&& cmake --build build -- install \
&& rm -rf build src
# Start from the (at the time of writing) latest Acts Ubuntu 20.04 image.
FROM ghcr.io/acts-project/ubuntu2004:v43

# DD4hep
# requires Geant4 and ROOT and must come last
RUN mkdir src \
&& ${GET} https://github.com/AIDASoft/DD4hep/archive/v01-21.tar.gz \
| ${UNPACK_TO_SRC} \
&& cmake -B build -S src -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DBUILD_TESTING=OFF \
-DDD4HEP_BUILD_PACKAGES="DDG4" \
-DDD4HEP_IGNORE_GEANT4_TLS=ON \
-DDD4HEP_USE_GEANT4=ON \
-DDD4HEP_USE_XERCESC=ON \
-DDD4HEP_USE_EDM4HEP=ON \
&& cmake --build build -- install \
&& rm -rf build src
# Some description for the image.
LABEL description="Ubuntu 20.04 with Acts dependencies and CUDA"
LABEL maintainer="Paul Gessinger <[email protected]"

# Onnx (download of tar.gz does not work out of the box, since the build.sh script requires a git repository)
RUN git clone https://github.com/microsoft/onnxruntime src \
&& (cd src && git checkout v1.13.1) \
&& ./src/build.sh \
--config MinSizeRel \
--build_shared_lib \
--build_dir build \
--skip_tests \
&& cmake --build build/MinSizeRel -- install \
&& rm -rf build src
# Add the Ubuntu 20.04 CUDA repository.
RUN curl -SL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb \
-o cuda-keyring.deb && \
dpkg -i cuda-keyring.deb && \
rm cuda-keyring.deb

# Install CUDA.
ARG CUDA_VERSION=12-4
RUN apt-get update && \
apt-get install -y cuda-compat-${CUDA_VERSION} cuda-cudart-${CUDA_VERSION} \
cuda-libraries-${CUDA_VERSION} \
cuda-command-line-tools-${CUDA_VERSION} \
cuda-minimal-build-${CUDA_VERSION} && \
apt-get clean -y

# Set up the CUDA environment.
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
104 changes: 54 additions & 50 deletions ubuntu2004_cuda_oneapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
# Docker machinery, part of the ACTS project
#
# Image building the Intel LLVM compiler from scratch, with Intel and NVidia
# backend support.
# (c) 2021-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# Base the image on the repository's ubuntu2004_cuda configuration.
FROM ghcr.io/acts-project/ubuntu2004_cuda:v36

# Build the Intel DPC++ compiler from source.
ARG LLVM_VERSION=2022-12
ARG LLVM_SOURCE_DIR=/root/llvm
ARG LLVM_BINARY_DIR=/root/build
RUN git clone https://github.com/intel/llvm.git ${LLVM_SOURCE_DIR} && \
cd ${LLVM_SOURCE_DIR}/ && git checkout ${LLVM_VERSION} && \
cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_INSTALL_LIBDIR=lib \
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \
-DLLVM_EXTERNAL_PROJECTS="sycl;sycl-fusion;llvm-spirv;opencl;libdevice;xpti;xptifw" \
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;sycl;sycl-fusion;llvm-spirv;opencl;libdevice;xpti;xptifw;libclc;lld;clang-tools-extra;openmp" \
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=${LLVM_SOURCE_DIR}/llvm-spirv \
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=${LLVM_SOURCE_DIR}/sycl \
-DLLVM_EXTERNAL_SYCL_FUSION_SOURCE_DIR=${LLVM_SOURCE_DIR}/sycl-fusion \
-DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR=${LLVM_SOURCE_DIR}/libdevice \
-DLLVM_EXTERNAL_XPTI_SOURCE_DIR=${LLVM_SOURCE_DIR}/xpti \
-DXPTI_SOURCE_DIR=${LLVM_SOURCE_DIR}/xpti \
-DLLVM_EXTERNAL_XPTIFW_SOURCE_DIR=${LLVM_SOURCE_DIR}/xptifw \
-DLIBCLC_TARGETS_TO_BUILD="nvptx64--;nvptx64--nvidiacl" \
-DLIBCLC_GENERATE_REMANGLED_VARIANTS=ON \
-DLLVM_BUILD_TOOLS=ON -DSYCL_ENABLE_WERROR=OFF \
-DSYCL_INCLUDE_TESTS=OFF -DLLVM_ENABLE_DOXYGEN=OFF \
-DLLVM_ENABLE_SPHINX=OFF -DBUILD_SHARED_LIBS=OFF \
-DSYCL_ENABLE_XPTI_TRACING=ON -DLLVM_ENABLE_LLD=OFF \
-DLLVM_ENABLE_PIC=ON -DLLVM_ENABLE_RTTI=ON -DXPTI_ENABLE_WERROR=OFF \
-DOpenCL_INSTALL_KHRONOS_ICD_LOADER=TRUE \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-DCMAKE_PREFIX_PATH=/usr/local/cuda/compat \
-DSYCL_ENABLE_PLUGINS="opencl;level_zero;cuda" \
-DSYCL_ENABLE_KERNEL_FUSION=ON \
-S ${LLVM_SOURCE_DIR}/llvm/ -B ${LLVM_BINARY_DIR} && \
export MAKEFLAGS=-j`nproc` && \
cmake --build ${LLVM_BINARY_DIR} --target intrinsics_gen && \
cmake --build ${LLVM_BINARY_DIR} && \
cmake --build ${LLVM_BINARY_DIR} --target sycl-toolchain && \
cmake --install ${LLVM_BINARY_DIR} && \
rm -rf ${LLVM_SOURCE_DIR} ${LLVM_BINARY_DIR}

# Set up the correct runtime environment for using the compiler(s).
ENV CC="${PREFIX}/bin/clang"
ENV CXX="${PREFIX}/bin/clang++"
ENV SYCLCXX="${CXX} -fsycl -fsycl-targets=nvptx64-nvidia-cuda"
ENV CUDAHOSTCXX="${CXX}"
ENV CUDAFLAGS="-std=c++17 -allow-unsupported-compiler"
# Start from the (at the time of writing) latest Acts Ubuntu 20.04 image.
FROM ghcr.io/acts-project/ubuntu2004:v43

# Some description for the image.
LABEL description="Ubuntu 20.04 with Acts dependencies and CUDA + oneAPI"
LABEL maintainer="Paul Gessinger <[email protected]"

# Add the Ubuntu 20.04 CUDA repository.
RUN curl -SL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb \
-o cuda-keyring.deb && \
dpkg -i cuda-keyring.deb && \
rm cuda-keyring.deb

# Install CUDA.
ARG CUDA_VERSION=12-4
RUN apt-get update && \
apt-get install -y cuda-compat-${CUDA_VERSION} cuda-cudart-${CUDA_VERSION} \
cuda-libraries-${CUDA_VERSION} \
cuda-command-line-tools-${CUDA_VERSION} \
cuda-minimal-build-${CUDA_VERSION} && \
apt-get clean -y

# Set up the CUDA environment.
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH}
ENV CUDAHOSTCXX="clang++"
ENV CUDAFLAGS="-allow-unsupported-compiler"

# Set up the Intel package signing key.
RUN mkdir --parents --mode=0755 /etc/apt/keyrings && \
curl -SL https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | \
gpg --dearmor > /usr/share/keyrings/oneapi-archive-keyring.gpg

# Set up the oneAPI repository.
COPY oneapi.list /etc/apt/sources.list.d/

# Install oneAPI.
ARG ONEAPI_VERSION=2024.1
RUN apt-get update && \
apt-get install -y intel-oneapi-compiler-dpcpp-cpp-${ONEAPI_VERSION} && \
apt-get clean -y

# Set up the oneAPI environment. Note that one *MUST* source the
# /opt/intel/oneapi/setvars.sh script to make the following work. Which has to
# be done in the respective CI scripts.
ENV CC="clang"
ENV CXX="clang++"
ENV SYCLCXX="clang++ -fsycl"
ENV SYCLFLAGS="-fsycl-targets=spir64,spir64_x86_64,nvidia_gpu_sm_75 -Wno-unknown-cuda-version -Xclang -opaque-pointers"
1 change: 1 addition & 0 deletions ubuntu2004_cuda_oneapi/oneapi.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main
Loading

0 comments on commit df7a9c0

Please sign in to comment.