Skip to content

Commit d6bf0cd

Browse files
authored
Merge pull request #9 from buffrr/ci-fixes
fix(ci): install protoc and pick a CUDA arch that builds without a GPU
2 parents abfae6c + 9481f46 commit d6bf0cd

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

prover/Dockerfile

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2323
libssl-dev \
2424
pkg-config \
2525
clang \
26+
protobuf-compiler \
2627
&& rm -rf /var/lib/apt/lists/*
2728

2829
# Rustup with no default toolchain; the repo's rust-toolchain.toml decides.
@@ -40,21 +41,50 @@ RUN rustc --version && cargo --version
4041

4142
# risc0 toolchain for guest-program build scripts in libveritas. Pin via
4243
# RISC0_VERSION for reproducible builds; empty means "latest".
44+
#
45+
# risc0-groth16 is installed explicitly: `subs-prover compress` runs
46+
# ProverOpts::groth16(), so without that component the binary builds fine and
47+
# then fails at runtime on the pod. Bare `rzup install` happens to include it,
48+
# but the pinned branch below would not.
4349
ARG RISC0_VERSION=
4450
RUN curl -L https://risczero.com/install | bash \
4551
&& if [ -n "${RISC0_VERSION}" ]; then \
4652
rzup install rust "${RISC0_VERSION}" && rzup install cpp; \
4753
else \
4854
rzup install; \
49-
fi
55+
fi \
56+
&& rzup install risc0-groth16
57+
58+
# Target GPU architectures for the risc0 CUDA kernels.
59+
#
60+
# risc0's build scripts hardcode `-arch=native`, which asks nvcc to detect the
61+
# local GPU. Build machines have none, so nvcc falls back to a default below
62+
# sm_60 and the compile dies on "CUDA atomics are only supported for sm_60 and
63+
# up". Those scripts skip `-arch=native` when NVCC_PREPEND_FLAGS is set, so
64+
# setting it is both how the arch gets chosen and how the broken default is
65+
# avoided.
66+
#
67+
# The default builds SASS for sm_80 (A100) plus compute_80 PTX, which the
68+
# driver JITs onto anything newer — RTX 4090 / L40S (sm_89) and H100 / H200
69+
# (sm_90) all run from it. That keeps this to one SASS target: each additional
70+
# one recompiles every kernel, and these kernels dominate the build.
71+
#
72+
# The cost is a one-off JIT pause the first time a non-A100 pod starts. Add an
73+
# explicit gencode for a card you run constantly to skip it, e.g.
74+
# --build-arg CUDA_ARCHS="-gencode arch=compute_90,code=sm_90 -gencode arch=compute_80,code=compute_80"
75+
ARG CUDA_ARCHS="-gencode arch=compute_80,code=sm_80 -gencode arch=compute_80,code=compute_80"
76+
ENV NVCC_PREPEND_FLAGS="${CUDA_ARCHS}"
5077

5178
# Cargo needs every workspace member present to resolve the manifest, even
5279
# though subs-prover only depends on types/. git stays installed above because
5380
# the workspace pulls certrelay and spaces_testutil as git dependencies.
5481
# See .dockerignore for exclusions.
5582
COPY . .
5683

57-
RUN cargo build --release -p subs-prover --features cuda --bin subs-prover
84+
# --locked so the committed Cargo.lock is enforced rather than merely
85+
# preferred; without it the image can silently resolve different versions than
86+
# the commit it claims to be built from.
87+
RUN cargo build --locked --release -p subs-prover --features cuda --bin subs-prover
5888

5989
# ----- Runtime stage -----------------------------------------------------
6090
FROM nvidia/cuda:12.4.0-runtime-ubuntu22.04

0 commit comments

Comments
 (0)