Auto-detect usable GPU (skip sm_120 RTX 5060, fallback to RTX 4060 Ti)

This commit is contained in:
Antoine Jacquin
2026-05-31 21:32:34 +02:00
parent 9119d63bc3
commit 5a9cdddcfb
2 changed files with 58 additions and 32 deletions

View File

@ -1,4 +1,4 @@
FROM nvidia/cuda:12.4.0-devel-ubuntu22.04
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
@ -45,15 +45,14 @@ RUN pip3 install --no-cache-dir \
pillow-avif-plugin \
cmcrameri
# Build CuPy from source with nvcc, targeting sm_120 (RTX 5060) and nearby archs.
# Pre-built wheels (cupy-cuda12x 14.x) don't include sm_120, so we compile.
# This step takes ~30 min the first time; the image is cached after that.
RUN apt-get update && apt-get install -y --no-install-recommends git && \
git clone --depth 1 --branch v14.0.0 https://github.com/cupy/cupy.git /tmp/cupy-src && \
cd /tmp/cupy-src && \
CUPY_NVCC_GENERATE_CODE='sm_89;sm_90;sm_120' \
pip3 install --no-cache-dir -e . && \
rm -rf /tmp/cupy-src
# CuPy 13.4 on CUDA 11.8 with JIT compilation (CUPY_CUDA_COMPILE_WITH_CACHE=1).
# JIT allows CuPy to compile kernels at runtime for GPU architectures not in
# the pre-built wheel (sm_89 = RTX 4060 Ti). nvcc must be in PATH at runtime.
# NOTE: RTX 5060 (sm_120) is NOT yet supported by any CuPy version.
# The pipeline auto-detects the best usable GPU (falls back to 4060 Ti).
ENV CUPY_CUDA_COMPILE_WITH_CACHE=1
ENV PATH=/usr/local/cuda/bin:${PATH}
RUN pip3 install --no-cache-dir cupy-cuda11x==13.4.0
# Copy and install the pipeline package
COPY setup.py .