Skip to content

Commit 9f7b894

Browse files
author
Nicholas Sielicki
committed
feat(ci): add package generation
stack-info: PR: #592, branch: aws-nslick/stack/33
1 parent ffd90fd commit 9f7b894

14 files changed

+605
-1
lines changed

.docker/Dockerfile.dnf

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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=fedora
8+
ARG VERSION=rawhide
9+
ARG VARIANT=cuda
10+
ARG CUDA_DISTRO
11+
ARG AWS_BUILD
12+
ARG ENABLE_POWERTOOLS
13+
14+
# Install EFA-installer deps.
15+
FROM ${FAMILY}:${VERSION} AS builder
16+
ARG CUDA_DISTRO
17+
ARG ENABLE_POWERTOOLS
18+
ENV CUDA_DISTRO=${CUDA_DISTRO}
19+
ENV ENABLE_POWERTOOLS=${ENABLE_POWERTOOLS}
20+
# Add NVIDIA repo for CUDA builds.
21+
COPY --from=efainstaller / /
22+
RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \
23+
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
24+
bash -c "cd /aws-efa-installer && dnf install -y gcc rpmdevtools rpmlint dnf-plugins-core util-linux && ./efa_installer.sh -n -l -k -d -y && rm -rf /aws-efa-installer" && \
25+
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_DISTRO}/$(uname -m)/cuda-${CUDA_DISTRO}.repo && \
26+
( test "${ENABLE_POWERTOOLS}" = "1" && sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/Rocky-PowerTools.repo || /bin/true ) && \
27+
dnf -y update && dnf -y upgrade
28+
RUN rpmdev-setuptree
29+
30+
FROM builder AS environment
31+
ARG VARIANT
32+
ARG AWS_BUILD
33+
ENV VARIANT=${VARIANT}
34+
ENV AWS_BUILD=${AWS_BUILD}
35+
COPY --from=srpm . .
36+
RUN yum search hwloc
37+
RUN echo "%with_${VARIANT} 1" >> ~/.rpmmacros
38+
RUN echo "%with_platform_aws ${AWS_BUILD}" >> ~/.rpmmacros
39+
RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \
40+
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
41+
dnf -y install cuda-cudart-devel-12-6 && dnf -y builddep *.src.rpm && rpmbuild --rebuild *.src.rpm
42+
43+
FROM scratch
44+
COPY --from=environment /root/rpmbuild/RPMS/**/* /

.docker/Dockerfile.dpkg

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+

.docker/Dockerfile.efa

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
FROM alpine:latest AS efa_installer_extracted
8+
ARG EFA_INSTALLER_VERSION=latest
9+
ENV EFA_INSTALLER_VERSION=${EFA_INSTALLER_VERSION}
10+
RUN apk add tar curl
11+
RUN mkdir /libfabric
12+
RUN curl -s -L https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz | tar -xvzf - -C /
13+
14+
FROM scratch
15+
COPY --from=efa_installer_extracted /aws-efa-installer /aws-efa-installer

.docker/Dockerfile.makedist

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 ACCELERATOR
8+
ARG BASE_IMAGE=ubuntu:22.04
9+
FROM ${BASE_IMAGE} AS distbuilder
10+
ARG ACCELERATOR
11+
ENV ACCELERATOR=${ACCELERATOR}
12+
RUN mkdir /aws-efa-installer
13+
COPY --from=efainstaller /aws-efa-installer /aws-efa-installer
14+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
15+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
16+
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 git libhwloc-dev make && rm -rf /aws-efa-installer"
17+
COPY ../ /proj
18+
WORKDIR /proj
19+
RUN autoreconf -ivf
20+
RUN ./configure --with-libfabric=/opt/amazon/efa --$(test "$ACCELERATOR" = "cuda" && echo "with-cuda=/usr/local/cuda" || echo "enable-neuron=yes") --with-libfabric=/opt/amazon/efa
21+
RUN make dist
22+
RUN ls -lart
23+
RUN pwd
24+
25+
FROM scratch
26+
COPY --from=distbuilder /proj/aws-ofi-nccl*.tar.gz /

.docker/Dockerfile.srpm

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
FROM fedora:rawhide AS packitimg
8+
RUN dnf install -y packit mock
9+
10+
FROM packitimg AS srpm
11+
RUN mkdir /proj
12+
WORKDIR /proj
13+
COPY --from=src . .
14+
COPY --from=makedist . .
15+
RUN packit srpm
16+
17+
FROM scratch
18+
COPY --from=srpm /proj/*.src.rpm /

.docker/Dockerfile.yum

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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=amazonlinux
8+
ARG VERSION=2
9+
ARG VARIANT=cuda
10+
ARG CUDA_DISTRO
11+
ARG AWS_BUILD
12+
13+
# Install EFA-installer deps.
14+
FROM ${FAMILY}:${VERSION} AS builder
15+
ARG CUDA_DISTRO
16+
ENV CUDA_DISTRO=${CUDA_DISTRO}
17+
# Add NVIDIA repo for CUDA builds.
18+
COPY --from=efainstaller / /
19+
RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \
20+
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
21+
bash -c "cd /aws-efa-installer && yum install -y gcc rpmdevtools rpmlint yum-utils util-linux && ./efa_installer.sh -n -l -k -d -y && rm -rf /aws-efa-installer" && \
22+
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/${CUDA_DISTRO}/$(uname -m)/cuda-${CUDA_DISTRO}.repo && \
23+
yum update -y
24+
RUN rpmdev-setuptree
25+
26+
FROM builder AS environment
27+
ARG VARIANT
28+
ARG AWS_BUILD
29+
ARG TOOLKIT_VERSION=12-6
30+
ENV VARIANT=${VARIANT}
31+
ENV AWS_BUILD=${AWS_BUILD}
32+
ENV TOOLKIT_VERSION=${TOOLKIT_VERSION}
33+
COPY --from=srpm . .
34+
RUN echo "%with_${VARIANT} 1" >> ~/.rpmmacros
35+
RUN echo "%with_platform_aws ${AWS_BUILD}" >> ~/.rpmmacros
36+
RUN echo "%_cuda_toolkit_version ${TOOLKIT_VERSION}" >> ~/.rpmmacros
37+
RUN --mount=type=cache,target=/var/cache/yum,sharing=locked \
38+
--mount=type=cache,target=/var/cache/dnf,sharing=locked \
39+
yum install -y cuda-cudart-devel-${TOOLKIT_VERSION} && yum-builddep -y *.src.rpm && rpmbuild --rebuild *.src.rpm
40+
41+
FROM scratch
42+
COPY --from=environment /root/rpmbuild/RPMS/**/* /

.github/workflows/packages.yaml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Package Generation
2+
on: [push, pull_request]
3+
jobs:
4+
dist:
5+
name: Call make dist
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v4
10+
- name: Set up QEMU
11+
uses: docker/setup-qemu-action@v3
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
14+
with:
15+
platforms: linux/amd64,linux/arm64
16+
- name: docker buildx bake makedist
17+
uses: docker/bake-action@v5
18+
with:
19+
set: |
20+
*.cache-from=type=gha
21+
*.cache-to=type=gha,mode=max
22+
push: true
23+
targets: makedist
24+
srpm:
25+
name: Generate a universal SRPM
26+
needs: [ dist ]
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
with:
36+
platforms: linux/amd64,linux/arm64
37+
- name: docker buildx bake srpm
38+
uses: docker/bake-action@v5
39+
with:
40+
set: |
41+
*.cache-from=type=gha
42+
*.cache-to=type=gha,mode=max
43+
push: true
44+
targets: srpm
45+
debs:
46+
name: Generate Debian-like Packages
47+
needs: [ dist ]
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v4
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
with:
57+
platforms: linux/amd64,linux/arm64
58+
- name: docker buildx bake debs
59+
uses: docker/bake-action@v5
60+
with:
61+
set: |
62+
*.cache-from=type=gha
63+
*.cache-to=type=gha,mode=max
64+
push: ${{ github.event_name != 'pull_request' }}
65+
targets: debs
66+
rpms:
67+
name: Generate RPM-like Packages
68+
needs: [ srpm ]
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout
72+
uses: actions/checkout@v4
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v3
75+
- name: Set up Docker Buildx
76+
uses: docker/setup-buildx-action@v3
77+
with:
78+
platforms: linux/amd64,linux/arm64
79+
- name: docker buildx bake rpms
80+
uses: docker/bake-action@v5
81+
with:
82+
set: |
83+
*.cache-from=type=gha
84+
*.cache-to=type=gha,mode=max
85+
push: ${{ github.event_name != 'pull_request' }}
86+
targets: rpms

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ m4/lt~obsolete.m4
7575
.idea/
7676
.devenv/
7777
.direnv
78+
*.src.rpm
79+
dockerbld

.packit.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
# vi:ts=2 sw=2 et:
3+
#
4+
# Docs: https://packit.dev/docs/
5+
6+
7+
srpm_build_deps:
8+
- git
9+
10+
actions:
11+
get-current-version:
12+
- bash -c "cat .version"
13+
create-archive:
14+
- bash -c "echo ./aws-ofi-nccl-${PACKIT_PROJECT_VERSION}.tar.gz"
15+
16+
specfile_path: .packit/libnccl-net-ofi.spec
17+
upstream_package_name: libnccl-net-ofi
18+
downstream_package_name: libnccl-net-ofi
19+
release_suffix: "{PACKIT_PROJECT_BRANCH}"
20+
update_release: false

0 commit comments

Comments
 (0)