From 64b586913d0d7241bd892975e82a122d3a904a5e Mon Sep 17 00:00:00 2001 From: BadStorm Developer Date: Sat, 12 Sep 2026 21:50:42 +0200 Subject: [PATCH] fix(qwentts): fix GPU detection race, make ROCm flash-attn build opt-in --- containers/qwentts/build-container.sh | 9 +++++++++ containers/qwentts/qwentts.Containerfile | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/containers/qwentts/build-container.sh b/containers/qwentts/build-container.sh index 2970c7d..b683a40 100755 --- a/containers/qwentts/build-container.sh +++ b/containers/qwentts/build-container.sh @@ -13,10 +13,19 @@ case "$DEVICE" in ;; esac +BUILD_FLASH_ATTN=false +if [ "$DEVICE" = "rocm" ]; then + read -r -p "Compilare anche flash-attn da sorgente? Richiede molto tempo (decine di minuti). [y/N] " reply + case "$reply" in + [yY]|[yY][eE][sS]) BUILD_FLASH_ATTN=true ;; + esac +fi + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" podman build \ --build-arg DEVICE="$DEVICE" \ + --build-arg BUILD_FLASH_ATTN="$BUILD_FLASH_ATTN" \ -t "localhost/qwentts:$DEVICE" \ -t localhost/qwentts:latest \ -f "$SCRIPT_DIR/qwentts.Containerfile" \ diff --git a/containers/qwentts/qwentts.Containerfile b/containers/qwentts/qwentts.Containerfile index 56a75b9..0e5ed52 100644 --- a/containers/qwentts/qwentts.Containerfile +++ b/containers/qwentts/qwentts.Containerfile @@ -6,6 +6,7 @@ ### BUILD (rocm): ./build-container.sh rocm ### RUN: podman run --rm -p 8000:8000 -v /path/to/models:/app/models qwentts:latest ARG DEVICE=cpu +ARG BUILD_FLASH_ATTN=false ARG BASE_IMAGE_CPU=python:3.12-slim ARG BASE_IMAGE_ROCM=docker.io/rocm/pytorch-nightly @@ -14,6 +15,7 @@ FROM ${BASE_IMAGE_ROCM} AS base-rocm FROM base-${DEVICE} ARG DEVICE +ARG BUILD_FLASH_ATTN USER root EXPOSE 8000 @@ -38,7 +40,7 @@ RUN if [ "$DEVICE" = "cpu" ]; then \ RUN pip install --no-cache-dir qwen-tts fastapi uvicorn python-multipart # Optional flash-attn for ROCm, built from source (PyPI wheel is CUDA-only); best-effort, skipped on failure -RUN if [ "$DEVICE" = "rocm" ]; then \ +RUN if [ "$DEVICE" = "rocm" ] && [ "$BUILD_FLASH_ATTN" = "true" ]; then \ pip install --no-cache-dir ninja \ && git clone --depth 1 https://github.com/Dao-AILab/flash-attention.git /tmp/flash-attention \ && (cd /tmp/flash-attention && GPU_ARCHS="gfx1150;gfx1151" python setup.py install) \