From 91cd6df108f39e23bd84a937d9b70f855b1b6831 Mon Sep 17 00:00:00 2001 From: Xariann <130084241+Xarianne@users.noreply.github.com> Date: Tue, 21 Jul 2026 06:26:25 +0100 Subject: [PATCH] fix(rocm): unset empty HSA_OVERRIDE_GFX_VERSION before torch loads (#864) Docker compose sets HSA_OVERRIDE_GFX_VERSION=${HSA_OVERRIDE_GFX_VERSION:-} which results in an empty string when not provided. An empty string is not the same as unset - ROCm treats it as 'force-empty' and no GPU is detected, even natively supported ones (e.g. gfx1201 / RX 9070 on ROCm 7.2). Pop the env var when it is empty, before torch loads, so ROCm auto-detects the GPU correctly. Tested on RX 9070 (gfx1201) with ROCm 7.2 and PyTorch 2.12.1+rocm7.2. --- backend/app.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/app.py b/backend/app.py index c63a2a6c..ea8411cb 100644 --- a/backend/app.py +++ b/backend/app.py @@ -38,6 +38,13 @@ logging.basicConfig( logger = logging.getLogger(__name__) +# An empty HSA_OVERRIDE_GFX_VERSION poisons the ROCm HSA runtime. It is +# treated as "force-empty" and no GPU is detected, even natively supported +# ones (e.g. gfx1201 / RX 9070 on ROCm 7.2). docker-compose can't +# conditionally omit an env var, so we clean it up here before torch loads. +if not os.environ.get("HSA_OVERRIDE_GFX_VERSION"): + os.environ.pop("HSA_OVERRIDE_GFX_VERSION", None) + # AMD GPU environment variables must be set before torch import # Only set HSA_OVERRIDE_GFX_VERSION for older GPUs that need it. # RDNA 3+ (gfx1100+) and RDNA 4 (gfx1200+) are natively supported by ROCm