|
| 1 | +# Base image |
1 | 2 | FROM ubuntu:22.04 |
2 | 3 |
|
| 4 | +# allow selecting oneAPI minor version at build time |
| 5 | +ARG ONEAPI_VER=2025.3 |
| 6 | +ENV ONEAPI_VER=${ONEAPI_VER} |
| 7 | + |
| 8 | +# Basic build tools |
3 | 9 | RUN apt-get update && apt-get install -y \ |
4 | | - bc cmake git gnupg gcc g++ python3-numpy sudo wget vim unzip \ |
5 | | - libcereal-dev libxc-dev libgtest-dev libgmock-dev libbenchmark-dev |
| 10 | + bc cmake git gnupg gcc g++ python3-numpy wget unzip ca-certificates \ |
| 11 | + vim sudo build-essential curl pkg-config \ |
| 12 | + libcereal-dev libxc-dev libgtest-dev libgmock-dev libbenchmark-dev \ |
| 13 | + && rm -rf /var/lib/apt/lists/* |
6 | 14 |
|
7 | | -# Following steps by https://software.intel.com/content/www/us/en/develop/documentation/installation-guide-for-intel-oneapi-toolkits-linux/top/installation/install-using-package-managers/apt.html . |
| 15 | +# Add Intel apt repo |
8 | 16 | RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ |
9 | | - | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ |
10 | | - echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ |
11 | | - | sudo tee /etc/apt/sources.list.d/oneAPI.list |
| 17 | + | gpg --dearmor --yes -o /usr/share/keyrings/oneapi-archive-keyring.gpg \ |
| 18 | + && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ |
| 19 | + > /etc/apt/sources.list.d/oneAPI.list |
12 | 20 |
|
13 | | -# To save disk space, only install the essential components, but not the whole toolkit. |
14 | | -RUN apt-get update && \ |
15 | | - apt-get install -y \ |
| 21 | +# Install essential oneAPI components (avoid pinning an exact mpi minor version) |
| 22 | +RUN apt-get update && apt-get install -y \ |
16 | 23 | intel-oneapi-compiler-dpcpp-cpp \ |
17 | 24 | intel-oneapi-compiler-fortran \ |
18 | 25 | intel-oneapi-mkl-devel \ |
19 | | - intel-oneapi-mpi-devel="2021.11.*" \ |
20 | | - intel-oneapi-vtune && \ |
21 | | - rm /opt/intel/oneapi/mpi/latest && ln -s /opt/intel/oneapi/mpi/2021.11 /opt/intel/oneapi/mpi/latest |
22 | | -ENV I_MPI_ROOT=/opt/intel/oneapi/mpi/latest \ |
23 | | - LIBRARY_PATH=/opt/intel/oneapi/tbb/latest/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/mpi/latest/lib:/opt/intel/oneapi/mkl/latest/lib/:/opt/intel/oneapi/ippcp/latest/lib/:/opt/intel/oneapi/ipp/latest/lib:/opt/intel/oneapi/dpl/latest/lib:/opt/intel/oneapi/dnnl/latest/lib:/opt/intel/oneapi/dal/latest/lib:/opt/intel/oneapi/compiler/latest/lib:/opt/intel/oneapi/ccl/latest/lib/ \ |
24 | | - LD_LIBRARY_PATH=/opt/intel/oneapi/tbb/latest/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/mpi/latest/opt/mpi/libfabric/lib:/opt/intel/oneapi/mpi/latest/lib:/opt/intel/oneapi/mkl/latest/lib:/opt/intel/oneapi/itac/latest/slib:/opt/intel/oneapi/ippcp/latest/lib/:/opt/intel/oneapi/ipp/latest/lib:/opt/intel/oneapi/dpl/latest/lib:/opt/intel/oneapi/dnnl/latest/lib:/opt/intel/oneapi/debugger/latest/opt/debugger/lib:/opt/intel/oneapi/dal/latest/lib:/opt/intel/oneapi/compiler/latest/opt/oclfpga/host/linux64/lib:/opt/intel/oneapi/compiler/latest/opt/compiler/lib:/opt/intel/oneapi/compiler/latest/lib:/opt/intel/oneapi/ccl/latest/lib/ \ |
25 | | - PATH=/opt/intel/oneapi/vtune/latest/bin64:/opt/intel/oneapi/mpi/latest/opt/mpi/libfabric/bin:/opt/intel/oneapi/mpi/latest/bin:/opt/intel/oneapi/mkl/latest/bin/:/opt/intel/oneapi/itac/latest/bin:/opt/intel/oneapi/inspector/latest/bin64:/opt/intel/oneapi/dpcpp-ct/latest/bin:/opt/intel/oneapi/dev-utilities/latest/bin:/opt/intel/oneapi/debugger/latest/opt/debugger/bin:/opt/intel/oneapi/compiler/latest/opt/oclfpga/bin:/opt/intel/oneapi/compiler/latest/bin:/opt/intel/oneapi/advisor/latest/bin64:/opt/mamba/bin:/opt/mamba/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ |
26 | | - MKLROOT=/opt/intel/oneapi/mkl/latest \ |
27 | | - FI_PROVIDER_PATH=/opt/intel/oneapi/mpi/latest/opt/mpi/libfabric/lib/prov:/usr/lib/x86_64-linux-gnu/libfabric \ |
28 | | - CMAKE_PREFIX_PATH=/opt/intel/oneapi/tbb/latest/env/..:/opt/intel/oneapi/mkl/latest/lib/cmake:/opt/intel/oneapi/ipp/latest/lib/cmake/ipp:/opt/intel/oneapi/dpl/latest/lib/cmake/oneDPL:/opt/intel/oneapi/dnnl/latest/lib/cmake:/opt/intel/oneapi/dal/latest:/opt/intel/oneapi/compiler/latest \ |
29 | | - CMPLR_ROOT=/opt/intel/oneapi/compiler/latest |
| 26 | + intel-oneapi-mpi-devel \ |
| 27 | + intel-oneapi-vtune \ |
| 28 | + && rm -rf /var/lib/apt/lists/* |
| 29 | + |
| 30 | +# Normalize 'latest' symlinks for mkl/mpi if possible; prefer requested ONEAPI_VER when present |
| 31 | +RUN set -eux; \ |
| 32 | + mkdir -p /opt/intel/oneapi; \ |
| 33 | + if [ -d "/opt/intel/oneapi/mkl/${ONEAPI_VER}" ]; then \ |
| 34 | + ln -sfn "/opt/intel/oneapi/mkl/${ONEAPI_VER}" /opt/intel/oneapi/mkl/latest; \ |
| 35 | + elif [ -d /opt/intel/oneapi/mkl ]; then \ |
| 36 | + ver=$(ls -1 /opt/intel/oneapi/mkl | sort -V | tail -n1 || true); \ |
| 37 | + [ -n "$ver" ] && ln -sfn "/opt/intel/oneapi/mkl/$ver" /opt/intel/oneapi/mkl/latest || true; \ |
| 38 | + fi; \ |
| 39 | + if [ -d "/opt/intel/oneapi/mpi/${ONEAPI_VER}" ]; then \ |
| 40 | + ln -sfn "/opt/intel/oneapi/mpi/${ONEAPI_VER}" /opt/intel/oneapi/mpi/latest; \ |
| 41 | + elif [ -d /opt/intel/oneapi/mpi ]; then \ |
| 42 | + ver=$(ls -1 /opt/intel/oneapi/mpi | sort -V | tail -n1 || true); \ |
| 43 | + [ -n "$ver" ] && ln -sfn "/opt/intel/oneapi/mpi/$ver" /opt/intel/oneapi/mpi/latest || true; \ |
| 44 | + fi; \ |
| 45 | + echo "MKL dirs:"; ls -la /opt/intel/oneapi/mkl || true; \ |
| 46 | + echo "MPI dirs:"; ls -la /opt/intel/oneapi/mpi || true |
| 47 | + |
| 48 | +# Set consistent envs referencing 'latest' symlink |
| 49 | +ENV I_MPI_ROOT=/opt/intel/oneapi/mpi/latest |
| 50 | +ENV MKLROOT=/opt/intel/oneapi/mkl/latest |
| 51 | +ENV LIBRARY_PATH=/opt/intel/oneapi/tbb/latest/env/../lib/intel64/gcc4.8:/opt/intel/oneapi/mpi/latest/lib:/opt/intel/oneapi/mkl/latest/lib |
| 52 | +ENV LD_LIBRARY_PATH=/opt/intel/oneapi/mpi/latest/lib:/opt/intel/oneapi/mkl/latest/lib |
| 53 | +ENV PATH=/opt/intel/oneapi/mpi/latest/bin:/opt/intel/oneapi/mkl/latest/bin:$PATH |
| 54 | +ENV CMAKE_PREFIX_PATH=/opt/intel/oneapi/mkl/latest/lib/cmake |
30 | 55 |
|
31 | 56 | SHELL ["/bin/bash", "-c"] |
32 | 57 | ENV CC=mpiicx CXX=mpiicpx FC=mpiifx |
33 | 58 |
|
34 | | -# https://elpa.mpcdf.mpg.de/software/tarball-archive/ELPA_TARBALL_ARCHIVE.html |
35 | | -RUN source /opt/intel/oneapi/setvars.sh && \ |
| 59 | +# Build ELPA (example dependency) |
| 60 | +RUN source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1 || true; \ |
36 | 61 | cd /tmp && \ |
37 | | - ELPA_VER=2022.11.001 && \ |
| 62 | + ELPA_VER=2025.06.001 && \ |
38 | 63 | wget -q https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/$ELPA_VER/elpa-$ELPA_VER.tar.gz && \ |
39 | | - tar xzf elpa-$ELPA_VER.tar.gz && rm elpa-$ELPA_VER.tar.gz && \ |
| 64 | + tar xzf elpa-$ELPA_VER.tar.gz && rm elpa-$ELPA_VER.tar.gz && \ |
40 | 65 | cd elpa-$ELPA_VER && mkdir build && cd build && \ |
41 | 66 | ../configure CFLAGS="-O3 -march=native" FCFLAGS="-O3 -qmkl=cluster" --enable-openmp && \ |
42 | | - make -j`nproc` && \ |
43 | | - make PREFIX=/usr/local install && \ |
44 | | - ln -s /usr/local/include/elpa_openmp-$ELPA_VER/elpa /usr/local/include/ && \ |
| 67 | + make -j"$(nproc)" && make PREFIX=/usr/local install && \ |
| 68 | + ln -sfn /usr/local/include/elpa_openmp-$ELPA_VER/elpa /usr/local/include/elpa || true && \ |
45 | 69 | cd /tmp && rm -rf elpa-$ELPA_VER |
46 | 70 |
|
47 | | -RUN cd /tmp && git clone https://github.com/Tencent/rapidjson.git && cp -r rapidjson/include/rapidjson /usr/include/ \ |
48 | | - && rm -rf rapidjson |
49 | | - |
50 | | -RUN wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip \ |
51 | | - --no-check-certificate --quiet -O libtorch.zip && \ |
52 | | - unzip -q libtorch.zip -d /opt && rm libtorch.zip |
53 | | - |
54 | | -ENV CMAKE_PREFIX_PATH=/opt/libtorch/share/cmake |
| 71 | +# rapidjson and libtorch |
| 72 | +RUN cd /tmp && git clone --depth 1 https://github.com/Tencent/rapidjson.git && cp -r rapidjson/include/rapidjson /usr/include/ && rm -rf rapidjson |
| 73 | +RUN wget -q https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcpu.zip -O /tmp/libtorch.zip && \ |
| 74 | + unzip -q /tmp/libtorch.zip -d /opt && rm -f /tmp/libtorch.zip |
| 75 | +ENV CMAKE_PREFIX_PATH=/opt/libtorch/share/cmake:${CMAKE_PREFIX_PATH} |
55 | 76 |
|
| 77 | +# Clone and build abacus (optional during image build; keep for CI image) |
56 | 78 | ADD https://api.github.com/repos/deepmodeling/abacus-develop/git/refs/heads/develop /dev/null |
57 | | - |
58 | | -RUN source /opt/intel/oneapi/setvars.sh && \ |
59 | | - git clone https://github.com/deepmodeling/abacus-develop.git --depth 1 && \ |
| 79 | +RUN set -eux; source /opt/intel/oneapi/setvars.sh >/dev/null 2>&1 || true; \ |
| 80 | + cd /tmp && git clone https://github.com/deepmodeling/abacus-develop.git --depth 1 && \ |
60 | 81 | cd abacus-develop && \ |
61 | 82 | cmake -B build -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_RAPIDJSON=ON && \ |
62 | | - cmake --build build -j`nproc` && \ |
| 83 | + cmake --build build -j"$(nproc)" && \ |
63 | 84 | cmake --install build && \ |
64 | | - rm -rf build && \ |
65 | | - abacus --version |
66 | | - #&& rm -rf abacus-develop |
| 85 | + /usr/bin/abacus --version || true && \ |
| 86 | + rm -rf /tmp/abacus-develop /tmp/abacus-develop.tar.gz |
| 87 | + |
| 88 | +# Default entry |
| 89 | +CMD ["/bin/bash"] |
0 commit comments