# Compile validation for rlx-cuda. Builds the crate inside an NVIDIA
# CUDA Linux container — verifies that:
# 1. cudarc + our kernel C++ sources compile in a real CUDA environment
# 2. The crate links against libcuda / libnvrtc when present
# 3. Nothing in the rest of the workspace breaks under linux-gnu
#
# Build:
# docker build -f rlx-cuda/Dockerfile.compile-check -t rlx-cuda-check .
#
# That's all — no `docker run`, no GPU passthrough required. Mac can't
# run CUDA kernels, but it CAN verify the build artifact is well-formed.
# Actual benchmarks must happen on a real CUDA box (vast.ai, Lambda,
# self-hosted CI runner).
FROM nvidia/cuda:12.6.0-devel-ubuntu22.04
# Toolchain. rustup pin matches what we run on Mac so kernels compile
# against the same Rust edition / cargo features.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl build-essential pkg-config \
&& rm -rf /var/lib/apt/lists/*
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
sh -s -- -y --default-toolchain stable --profile minimal
ENV PATH=/root/.cargo/bin:$PATH
WORKDIR /work
# Copy the workspace (sparse — just the crates rlx-cuda depends on).
COPY Cargo.toml Cargo.lock ./
COPY rlx-ir rlx-ir
COPY rlx-opt rlx-opt
COPY rlx-driver rlx-driver
COPY rlx-cuda rlx-cuda
# Strip workspace members that aren't needed for the cuda compile check.
# Keeping it minimal avoids pulling in metal, mlx, wgpu, models etc.
RUN sed -i 's|"rlx-cpu",|# "rlx-cpu",|; \
s|"rlx-metal",|# "rlx-metal",|; \
s|"rlx-mlx",|# "rlx-mlx",|; \
s|"rlx-wgpu",|# "rlx-wgpu",|; \
s|"rlx-gguf",|# "rlx-gguf",|; \
s|"rlx-macros",|# "rlx-macros",|; \
s|"rlx-runtime",|# "rlx-runtime",|;' Cargo.toml
# Verify rlx-cuda compiles cleanly under linux-gnu with NVRTC available.
RUN cargo build -p rlx-cuda --release 2>&1 | tail -20
# Optional: run the basic tests. They no-op without a GPU but verify
# the test harness compiles and the unit-test path links.
RUN cargo test -p rlx-cuda --release --no-run 2>&1 | tail -10
CMD ["echo", "rlx-cuda compile check passed"]