|
| 1 | +# |
| 2 | +# Copyright (c) 2024, Amazon.com, Inc. or its affiliates. All rights reserved. |
| 3 | +# |
| 4 | +# See LICENSE.txt for license information |
| 5 | +# |
| 6 | + |
| 7 | +ARG FAMILY=ubuntu |
| 8 | +ARG VERSION=latest |
| 9 | +ARG CUDA_DISTRO |
| 10 | +ARG DEBIAN_FRONTEND=noninteractive |
| 11 | +ARG AWS_BUILD |
| 12 | + |
| 13 | +FROM ${FAMILY}:${VERSION} AS build |
| 14 | +ARG CUDA_DISTRO |
| 15 | +ENV CUDA_DISTRO=${CUDA_DISTRO} |
| 16 | +ARG AWS_BUILD=0 |
| 17 | +ENV AWS_BUILD=${AWS_BUILD} |
| 18 | + |
| 19 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 20 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 21 | + apt-get update -y && apt-get install wget -y |
| 22 | + |
| 23 | +RUN wget https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_DISTRO}/$(uname -m)/cuda-keyring_1.1-1_all.deb |
| 24 | + |
| 25 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 26 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 27 | + dpkg -i cuda-keyring_1.1-1_all.deb |
| 28 | + |
| 29 | +COPY --from=efainstaller / . |
| 30 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 31 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 32 | + bash -c "apt-get update -y && cd /aws-efa-installer && ./efa_installer.sh /efa_installer.sh -n -l -k -d -y && apt-get install -y autoconf automake libtool gcc g++ git libhwloc-dev make && rm -rf /aws-efa-installer" |
| 33 | + |
| 34 | +COPY --from=makedist / . |
| 35 | +RUN tar xvf ./aws-ofi-nccl*.tar.gz -C . |
| 36 | +RUN cd aws-ofi-nccl* && \ |
| 37 | + ./configure --$(test "$ACCELERATOR" = "cuda" && echo "with-cuda=/usr/local/cuda" || echo "enable-neuron=yes") \ |
| 38 | + --prefix=/opt/amazon/libnccl-net-ofi$(test "$AWS_BUILD" -eq 0 || echo -n "-aws") \ |
| 39 | + --with-libfabric=/opt/amazon/efa \ |
| 40 | + --disable-tests \ |
| 41 | + --$(test "$AWS_BUILD" -eq 0 && echo -n "disable" || echo -n "enable")-platform-aws \ |
| 42 | + --with-mpi=no && make -j && make install |
| 43 | + |
| 44 | +FROM ubuntu:latest AS packager |
| 45 | +ARG FAMILY |
| 46 | +ARG VERSION |
| 47 | +ARG AWS_BUILD=0 |
| 48 | +ENV AWS_BUILD=${AWS_BUILD} |
| 49 | +ENV FAMILY=${FAMILY} |
| 50 | +ENV VERSION=${VERSION} |
| 51 | +COPY --from=build /opt/amazon/ /opt/amazon/ |
| 52 | +RUN find /opt/amazon/ | grep -E \.la$ | xargs rm |
| 53 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 54 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 55 | + apt-get update -y && apt-get install -y ruby tar squashfs-tools binutils && gem install fpm |
| 56 | +RUN fpm \ |
| 57 | + -s dir -t deb \ |
| 58 | + --license Apache2.0 \ |
| 59 | + -p /libnccl-net-ofi$(test "$AWS_BUILD" -eq 0 || echo -n "-aws")-${FAMILY}-${VERSION}.deb \ |
| 60 | + --name nccl-net-ofi$(test "$AWS_BUILD" -eq 0 || echo -n "-aws") \ |
| 61 | + /opt/amazon/libnccl-net-ofi$(test "$AWS_BUILD" -eq 0 || echo -n "-aws")/=/opt/amazon/libnccl-net-ofi$(test "$AWS_BUILD" -eq 0 || echo -n "-aws") |
| 62 | + |
| 63 | +FROM scratch |
| 64 | +COPY --from=packager /libnccl-net-ofi* / |
| 65 | + |
0 commit comments