Skip to content

Commit 4095383

Browse files
authored
Update Docker and CI for multi-architecture support (#233)
* Update Docker and CI for multi-architecture support Build LLVM 7.1.0 from source for consistent versions across architectures. 7.1.0 is basically the same as 7.0.1. Add native ARM64 runner support in GitHub Actions workflow. Implement two-phase build process with manifest lists for multi-arch images. Add build optimizations and caching to improve CI performance.
1 parent f3328b5 commit 4095383

File tree

5 files changed

+270
-58
lines changed

5 files changed

+270
-58
lines changed

.github/workflows/container_images.yml

Lines changed: 97 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,47 @@ env:
1414
REGISTRY: ghcr.io
1515
jobs:
1616
build-images:
17-
name: ${{ matrix.variance.name }}
18-
runs-on: ubuntu-latest
17+
name: Build ${{ matrix.variance.name }} (${{ matrix.platform.arch }})
18+
runs-on: ${{ matrix.platform.runner }}
1919
permissions:
2020
contents: read
2121
packages: write
22-
attestations: write
23-
id-token: write
2422
strategy:
2523
fail-fast: false
2624
matrix:
25+
platform:
26+
- runner: ubuntu-latest
27+
arch: amd64
28+
- runner: ubuntu-24.04-arm
29+
arch: arm64
2730
variance:
2831
- name: Ubuntu-22.04/CUDA-11.8.0
29-
image: "${{ github.repository }}-ubuntu22-cuda11"
32+
image: "rust-gpu/rust-cuda-ubuntu22-cuda11"
3033
dockerfile: ./container/ubuntu22-cuda11/Dockerfile
3134
- name: Ubuntu-22.04/CUDA-12.8.1
32-
image: "${{ github.repository }}-ubuntu22-cuda12"
35+
image: "rust-gpu/rust-cuda-ubuntu22-cuda12"
3336
dockerfile: ./container/ubuntu22-cuda12/Dockerfile
3437
- name: Ubuntu-24.04/CUDA-12.8.1
35-
image: "${{ github.repository }}-ubuntu24-cuda12"
38+
image: "rust-gpu/rust-cuda-ubuntu24-cuda12"
3639
dockerfile: ./container/ubuntu24-cuda12/Dockerfile
3740
- name: RockyLinux-9/CUDA-12.8.1
38-
image: "${{ github.repository }}-rockylinux9-cuda12"
41+
image: "rust-gpu/rust-cuda-rockylinux9-cuda12"
3942
dockerfile: ./container/rockylinux9-cuda12/Dockerfile
4043
steps:
4144
- name: Checkout repository
4245
uses: actions/checkout@v4
46+
- name: Validate platform
47+
run: |
48+
ARCH=$(uname -m)
49+
if [[ "${{ matrix.platform.arch }}" == "amd64" && "$ARCH" != "x86_64" ]]; then
50+
echo "Error: Expected x86_64 but got $ARCH"
51+
exit 1
52+
fi
53+
if [[ "${{ matrix.platform.arch }}" == "arm64" && "$ARCH" != "aarch64" ]]; then
54+
echo "Error: Expected aarch64 but got $ARCH"
55+
exit 1
56+
fi
57+
echo "Platform validation passed: $ARCH matches ${{ matrix.platform.arch }}"
4358
- name: Log in to the Container registry
4459
uses: docker/login-action@v3
4560
with:
@@ -51,24 +66,85 @@ jobs:
5166
uses: docker/metadata-action@v5
5267
with:
5368
images: ${{ env.REGISTRY }}/${{ matrix.variance.image }}
54-
tags: |
55-
type=ref,event=branch
56-
type=sha,format=short
57-
type=raw,value=latest
5869
- name: Set up Docker Buildx
5970
uses: docker/setup-buildx-action@v3
60-
- name: Build and push container images
61-
id: push
71+
- name: Build and push by digest
72+
id: build
6273
uses: docker/build-push-action@v6
6374
with:
6475
context: .
6576
file: ${{ matrix.variance.dockerfile }}
66-
tags: ${{ steps.meta.outputs.tags }}
77+
platforms: linux/${{ matrix.platform.arch }}
6778
labels: ${{ steps.meta.outputs.labels }}
68-
push: ${{ github.event_name != 'pull_request' }}
69-
- name: Generate artifact attestation
70-
uses: actions/attest-build-provenance@v2
79+
outputs: type=image,name=${{ env.REGISTRY }}/${{ matrix.variance.image }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
- name: Export digest
83+
if: github.event_name != 'pull_request'
84+
run: |
85+
mkdir -p /tmp/digests
86+
digest="${{ steps.build.outputs.digest }}"
87+
touch "/tmp/digests/${digest#sha256:}"
88+
- name: Upload digest
89+
if: github.event_name != 'pull_request'
90+
uses: actions/upload-artifact@v4
7191
with:
72-
subject-name: ${{ env.REGISTRY }}/${{ matrix.variance.image }}
73-
subject-digest: ${{ steps.push.outputs.digest }}
74-
push-to-registry: true
92+
name: digests-${{ matrix.variance.image }}-${{ matrix.platform.arch }}
93+
path: /tmp/digests/*
94+
if-no-files-found: error
95+
retention-days: 1
96+
97+
merge-manifests:
98+
name: Create manifest for ${{ matrix.variance.name }}
99+
runs-on: ubuntu-latest
100+
if: github.event_name != 'pull_request'
101+
needs: build-images
102+
permissions:
103+
contents: read
104+
packages: write
105+
attestations: write
106+
id-token: write
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
variance:
111+
- name: Ubuntu-22.04/CUDA-11.8.0
112+
image: "rust-gpu/rust-cuda-ubuntu22-cuda11"
113+
- name: Ubuntu-22.04/CUDA-12.8.1
114+
image: "rust-gpu/rust-cuda-ubuntu22-cuda12"
115+
- name: Ubuntu-24.04/CUDA-12.8.1
116+
image: "rust-gpu/rust-cuda-ubuntu24-cuda12"
117+
- name: RockyLinux-9/CUDA-12.8.1
118+
image: "rust-gpu/rust-cuda-rockylinux9-cuda12"
119+
steps:
120+
- name: Download digests
121+
uses: actions/download-artifact@v4
122+
with:
123+
path: /tmp/digests
124+
pattern: digests-${{ matrix.variance.image }}-*
125+
merge-multiple: true
126+
- name: Set up Docker Buildx
127+
uses: docker/setup-buildx-action@v3
128+
- name: Docker meta
129+
id: meta
130+
uses: docker/metadata-action@v5
131+
with:
132+
images: ${{ env.REGISTRY }}/${{ matrix.variance.image }}
133+
tags: |
134+
type=ref,event=branch
135+
type=sha,format=short
136+
type=raw,value=latest
137+
- name: Login to Registry
138+
uses: docker/login-action@v3
139+
with:
140+
registry: ${{ env.REGISTRY }}
141+
username: ${{ github.actor }}
142+
password: ${{ secrets.GITHUB_TOKEN }}
143+
- name: Create manifest list and push
144+
working-directory: /tmp/digests
145+
run: |
146+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
147+
$(printf '${{ env.REGISTRY }}/${{ matrix.variance.image }}@sha256:%s ' *)
148+
- name: Inspect image
149+
run: |
150+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ matrix.variance.image }}:${{ steps.meta.outputs.version }}

container/rockylinux9-cuda12/Dockerfile

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM nvidia/cuda:12.8.1-cudnn-devel-rockylinux9
22

3-
RUN dnf -y install \
3+
RUN dnf -y update && \
4+
dnf -y install \
45
clang \
56
openssl-devel \
67
pkgconfig \
@@ -20,16 +21,50 @@ RUN dnf -y install \
2021
libXrandr-devel && \
2122
dnf clean all
2223

23-
# Get LLVM 7 & libffi.so.6
24+
# Get LLVM 7
2425
WORKDIR /data/llvm7
25-
RUN curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/l/libffi3.1-3.1-36.el9.x86_64.rpm && \
26-
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-7.0.1-7.el8.x86_64.rpm && \
27-
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-devel-7.0.1-7.el8.x86_64.rpm && \
28-
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-libs-7.0.1-7.el8.x86_64.rpm && \
29-
curl -sSf -L -O https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/l/llvm7.0-static-7.0.1-7.el8.x86_64.rpm && \
30-
dnf -y install ./*.rpm && \
31-
ln -s /usr/bin/llvm-config-7-64 /usr/bin/llvm-config && \
32-
rm -rf ./*.rpm && \
26+
27+
# Install dependencies for building LLVM
28+
RUN dnf -y install epel-release && \
29+
dnf -y install \
30+
libffi-devel \
31+
ncurses-devel \
32+
libxml2-devel \
33+
libedit-devel \
34+
python3 \
35+
make && \
36+
dnf clean all
37+
38+
# Download and build LLVM 7.1.0 for all architectures
39+
RUN curl -sSf -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-7.1.0/llvm-7.1.0.src.tar.xz && \
40+
tar -xf llvm-7.1.0.src.tar.xz && \
41+
cd llvm-7.1.0.src && \
42+
mkdir build && cd build && \
43+
ARCH=$(uname -m) && \
44+
if [ "$ARCH" = "x86_64" ]; then \
45+
TARGETS="X86;NVPTX"; \
46+
else \
47+
TARGETS="AArch64;NVPTX"; \
48+
fi && \
49+
cmake \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DLLVM_TARGETS_TO_BUILD="$TARGETS" \
52+
-DLLVM_BUILD_LLVM_DYLIB=ON \
53+
-DLLVM_LINK_LLVM_DYLIB=ON \
54+
-DLLVM_ENABLE_ASSERTIONS=OFF \
55+
-DLLVM_ENABLE_BINDINGS=OFF \
56+
-DLLVM_INCLUDE_EXAMPLES=OFF \
57+
-DLLVM_INCLUDE_TESTS=OFF \
58+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
59+
-DLLVM_ENABLE_ZLIB=ON \
60+
-DLLVM_ENABLE_TERMINFO=ON \
61+
-DCMAKE_INSTALL_PREFIX=/usr \
62+
.. && \
63+
make -j$(nproc) && \
64+
make install && \
65+
cd ../.. && \
66+
rm -rf llvm-7.1.0.src* && \
67+
ln -s /usr/bin/llvm-config /usr/bin/llvm-config-7 && \
3368
dnf clean all
3469

3570
# Get Rust
@@ -44,4 +79,4 @@ RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-too
4479
# Add nvvm to LD_LIBRARY_PATH.
4580
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"
4681
ENV LLVM_LINK_STATIC=1
47-
ENV RUST_LOG=info
82+
ENV RUST_LOG=info

container/ubuntu22-cuda11/Dockerfile

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,48 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
2424

2525
# Get LLVM 7
2626
WORKDIR /data/llvm7
27-
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb && \
28-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb && \
29-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb && \
30-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb && \
31-
apt-get update && apt-get install -y ./*.deb && \
32-
ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config && \
33-
rm -rf ./*.deb && \
27+
28+
# Install dependencies for building LLVM
29+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
30+
libffi-dev \
31+
libedit-dev \
32+
libncurses5-dev \
33+
libxml2-dev \
34+
python3 \
35+
ninja-build && \
3436
rm -rf /var/lib/apt/lists/*
3537

38+
# Download and build LLVM 7.1.0 for all architectures
39+
RUN curl -sSf -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-7.1.0/llvm-7.1.0.src.tar.xz && \
40+
tar -xf llvm-7.1.0.src.tar.xz && \
41+
cd llvm-7.1.0.src && \
42+
mkdir build && cd build && \
43+
ARCH=$(dpkg --print-architecture) && \
44+
if [ "$ARCH" = "amd64" ]; then \
45+
TARGETS="X86;NVPTX"; \
46+
else \
47+
TARGETS="AArch64;NVPTX"; \
48+
fi && \
49+
cmake -G Ninja \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DLLVM_TARGETS_TO_BUILD="$TARGETS" \
52+
-DLLVM_BUILD_LLVM_DYLIB=ON \
53+
-DLLVM_LINK_LLVM_DYLIB=ON \
54+
-DLLVM_ENABLE_ASSERTIONS=OFF \
55+
-DLLVM_ENABLE_BINDINGS=OFF \
56+
-DLLVM_INCLUDE_EXAMPLES=OFF \
57+
-DLLVM_INCLUDE_TESTS=OFF \
58+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
59+
-DLLVM_ENABLE_ZLIB=ON \
60+
-DLLVM_ENABLE_TERMINFO=ON \
61+
-DCMAKE_INSTALL_PREFIX=/usr \
62+
.. && \
63+
ninja -j$(nproc) && \
64+
ninja install && \
65+
cd ../.. && \
66+
rm -rf llvm-7.1.0.src* && \
67+
ln -s /usr/bin/llvm-config /usr/bin/llvm-config-7
68+
3669
# Get Rust
3770
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
3871
ENV PATH="/root/.cargo/bin:${PATH}"
@@ -45,4 +78,5 @@ RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-too
4578
# Add nvvm to LD_LIBRARY_PATH.
4679
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"
4780
ENV LLVM_LINK_STATIC=1
48-
ENV RUST_LOG=info
81+
ENV RUST_LOG=info
82+

container/ubuntu22-cuda12/Dockerfile

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,48 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
2424

2525
# Get LLVM 7
2626
WORKDIR /data/llvm7
27-
RUN curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7_7.0.1-12_amd64.deb && \
28-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-dev_7.0.1-12_amd64.deb && \
29-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/libllvm7_7.0.1-12_amd64.deb && \
30-
curl -sSf -L -O http://mirrors.kernel.org/ubuntu/pool/universe/l/llvm-toolchain-7/llvm-7-runtime_7.0.1-12_amd64.deb && \
31-
apt-get update && apt-get install -y ./*.deb && \
32-
ln -s /usr/bin/llvm-config-7 /usr/bin/llvm-config && \
33-
rm -rf ./*.deb && \
27+
28+
# Install dependencies for building LLVM
29+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install \
30+
libffi-dev \
31+
libedit-dev \
32+
libncurses5-dev \
33+
libxml2-dev \
34+
python3 \
35+
ninja-build && \
3436
rm -rf /var/lib/apt/lists/*
3537

38+
# Download and build LLVM 7.1.0 for all architectures
39+
RUN curl -sSf -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-7.1.0/llvm-7.1.0.src.tar.xz && \
40+
tar -xf llvm-7.1.0.src.tar.xz && \
41+
cd llvm-7.1.0.src && \
42+
mkdir build && cd build && \
43+
ARCH=$(dpkg --print-architecture) && \
44+
if [ "$ARCH" = "amd64" ]; then \
45+
TARGETS="X86;NVPTX"; \
46+
else \
47+
TARGETS="AArch64;NVPTX"; \
48+
fi && \
49+
cmake -G Ninja \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DLLVM_TARGETS_TO_BUILD="$TARGETS" \
52+
-DLLVM_BUILD_LLVM_DYLIB=ON \
53+
-DLLVM_LINK_LLVM_DYLIB=ON \
54+
-DLLVM_ENABLE_ASSERTIONS=OFF \
55+
-DLLVM_ENABLE_BINDINGS=OFF \
56+
-DLLVM_INCLUDE_EXAMPLES=OFF \
57+
-DLLVM_INCLUDE_TESTS=OFF \
58+
-DLLVM_INCLUDE_BENCHMARKS=OFF \
59+
-DLLVM_ENABLE_ZLIB=ON \
60+
-DLLVM_ENABLE_TERMINFO=ON \
61+
-DCMAKE_INSTALL_PREFIX=/usr \
62+
.. && \
63+
ninja -j$(nproc) && \
64+
ninja install && \
65+
cd ../.. && \
66+
rm -rf llvm-7.1.0.src* && \
67+
ln -s /usr/bin/llvm-config /usr/bin/llvm-config-7
68+
3669
# Get Rust
3770
RUN curl -sSf -L https://sh.rustup.rs | bash -s -- -y
3871
ENV PATH="/root/.cargo/bin:${PATH}"
@@ -45,4 +78,5 @@ RUN --mount=type=bind,source=rust-toolchain.toml,target=/data/Rust-CUDA/rust-too
4578
# Add nvvm to LD_LIBRARY_PATH.
4679
ENV LD_LIBRARY_PATH="/usr/local/cuda/nvvm/lib64:${LD_LIBRARY_PATH}"
4780
ENV LLVM_LINK_STATIC=1
48-
ENV RUST_LOG=info
81+
ENV RUST_LOG=info
82+

0 commit comments

Comments
 (0)