Simplify CUDA build workflow by removing Dockerfile

Replace multi-stage Docker build with direct use of cuda-builder image
for building and stripping quantus-miner binaries, streamlining CI
steps.
This commit is contained in:
rob thijssen
2025-09-13 06:07:01 +03:00
parent 8db0496b88
commit 8a6de1a53f
2 changed files with 14 additions and 132 deletions
+14 -43
View File
@@ -36,61 +36,32 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- uses: ./.github/actions/disk
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prepare Buildx cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.cuda_tag }}-sm${{ matrix.sm }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.cuda_tag }}-sm${{ matrix.sm }}-
- name: Build miner image and export dist filesystem
- name: Build with cuda-builder image
id: build
env:
CUDA_TAG: ${{ matrix.cuda_tag }}
SM: ${{ matrix.sm }}
run: |
set -eux
# Build the dist stage and export its filesystem to ./out
docker buildx build \
--progress=plain \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max \
--target dist \
--output type=local,dest=./out \
--build-arg CUDA_TAG=${CUDA_TAG} \
--build-arg SM=${SM} \
-f Containerfile .
# Move new cache into place to avoid unbounded growth
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Collect binary artifact
id: extract
env:
CUDA_TAG: ${{ matrix.cuda_tag }}
SM: ${{ matrix.sm }}
run: |
set -eux
# Short CUDA tag (e.g., 12.9 from 12.9.0)
SHORT_TAG="$(echo "${CUDA_TAG}" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/')"
BIN="quantus-miner-cuda-${SHORT_TAG}-sm-${SM}"
# Binary exported by the dist stage is under ./out/usr/local/bin
install -m 0755 ./out/usr/local/bin/quantus-miner "./${BIN}"
mkdir -p .cargo-cache target
docker run --rm \
-e CUDA_ARCH=sm_${SM} \
-e CARGO_TERM_COLOR=always \
-v "${PWD}:/workspace" \
-v "${PWD}/.cargo-cache:/opt/cargo/registry" \
-v "${PWD}/target:/workspace/target" \
ghcr.io/quantus-network/cuda-builder:${CUDA_TAG} \
bash -lc 'cd /workspace && echo "CUDA version:" && nvcc --version && cargo build -p miner-cli --features cuda --release && strip target/release/quantus-miner || true'
install -m 0755 ./target/release/quantus-miner "./${BIN}"
echo "bin_path=./${BIN}" >> "$GITHUB_OUTPUT"
echo "short_tag=${SHORT_TAG}" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ format('quantus-miner-cuda-{0}-sm-{1}', steps.extract.outputs.short_tag, matrix.sm) }}
path: ${{ steps.extract.outputs.bin_path }}
name: ${{ format('quantus-miner-cuda-{0}-sm-{1}', steps.build.outputs.short_tag, matrix.sm) }}
path: ${{ steps.build.outputs.bin_path }}
if-no-files-found: error
retention-days: 3
-89
View File
@@ -1,89 +0,0 @@
# syntax=docker/dockerfile:1.7
# Containerized CUDA build for Quantus Miner.
# Supports matrix builds via:
# - CUDA_TAG: CUDA toolkit tag (e.g., 12.9.0, 13.0.0)
# - SM: GPU SM architecture (e.g., 86 for RTX 3060, 89 for RTX 4090, 120 for CC 12.0)
#
# Examples (podman or docker):
# podman build -t quantus-miner:cuda12.9-sm86 \
# --build-arg CUDA_TAG=12.9.0 --build-arg SM=86 -f Containerfile .
#
# podman build -t quantus-miner:cuda13.0-sm89 \
# --build-arg CUDA_TAG=13.0.0 --build-arg SM=89 -f Containerfile .
#
# The resulting image contains /usr/local/bin/quantus-miner.
# You can extract the binary for distribution:
# cid=$(podman create quantus-miner:cuda12.9-sm86)
# podman cp "$cid":/usr/local/bin/quantus-miner ./quantus-miner-cuda-12.9-sm-86
# podman rm "$cid"
################################################################################
# Stage 1: Build with NVIDIA CUDA devel + Rust
################################################################################
ARG CUDA_TAG=12.9.0
FROM nvcr.io/nvidia/cuda:${CUDA_TAG}-devel-ubuntu22.04 AS builder
ARG CUDA_TAG
ENV CUDA_TAG=${CUDA_TAG}
# SM arch for the device code (86=Ampere 3060, 89=Ada 4090, 120=CC 12.0/5090).
ARG SM=86
ENV SM=${SM}
# System deps for Rust toolchain and linking
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl ca-certificates pkg-config build-essential \
libssl-dev git clang cmake && \
rm -rf /var/lib/apt/lists/*
# Install Rust (stable)
ENV RUSTUP_HOME=/opt/rustup \
CARGO_HOME=/opt/cargo \
CUDA_HOME=/usr/local/cuda \
CARGO_TERM_COLOR=always \
PATH=/opt/cargo/bin:/usr/local/cuda/bin:${PATH}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal --default-toolchain stable && \
rustc --version && cargo --version
WORKDIR /src
# (Optional) set CUDA arch for build.rs (normalized internally to compute_XX/sm_XX)
ENV CUDA_ARCH=sm_${SM}
# (Optional) permit newer host compilers inside future images if needed
# ENV MINER_CUDA_ALLOW_UNSUPPORTED_COMPILER=1
# (Optional) select specific host C++ compiler for nvcc (only if needed)
# ENV MINER_NVCC_CCBIN=/usr/bin/g++-14
# Copy manifests first to leverage build cache
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
# Build the miner with CUDA feature (kernels compiled & embedded by build.rs)
# Cache Cargo registry and target dirs for faster matrix builds.
RUN --mount=type=cache,target=/opt/cargo/registry \
--mount=type=cache,target=/src/target \
set -eux; \
echo "CUDA version:" && nvcc --version; \
echo "Building for SM=${SM}, CUDA_TAG=${CUDA_TAG} (CUDA_ARCH=${CUDA_ARCH})"; \
cargo build -p miner-cli --features cuda --release; \
strip /src/target/release/quantus-miner || true; \
mkdir -p /artifacts; \
cp -a /src/target/release/quantus-miner /artifacts/quantus-miner
################################################################################
# Stage 2: Minimal runtime image with the miner binary
################################################################################
FROM ubuntu:22.04 AS dist
# Ensure certificates exist (for any outbound metrics/HTTP if used)
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /artifacts/quantus-miner /usr/local/bin/quantus-miner
# Default entrypoint; override with args as needed
ENTRYPOINT ["/usr/local/bin/quantus-miner"]