Skip to content

Commit 2d32d52

Browse files
committed
fix(deploy): fallback through ROCm versions for PyTorch wheels
PyTorch only publishes wheels for specific ROCm versions (e.g. 6.2, 7.0, 7.1) — not every point release. For ROCm 7.2, deploy now tries: 7.2 → 7.1 → 7.0 → 6.4 → 6.3 → 6.2 → 6.1 → 6.0 Stops at first successful install. Falls back to PyPI CPU torch if no ROCm wheels found at all.
1 parent 58f3d54 commit 2d32d52

File tree

1 file changed

+30
-3
lines changed
  • skills/detection/yolo-detection-2026

1 file changed

+30
-3
lines changed

skills/detection/yolo-detection-2026/deploy.sh

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,36 @@ if [ "$BACKEND" = "rocm" ]; then
173173
ROCM_VER="${ROCM_VER:-6.2}" # fallback if detection fails
174174
log "Detected ROCm version: $ROCM_VER"
175175

176-
# Phase 1: PyTorch from ROCm index (--index-url forces ROCm build, not CUDA)
177-
log "Installing PyTorch with ROCm $ROCM_VER support..."
178-
"$PIP" install torch torchvision --index-url "https://download.pytorch.org/whl/rocm${ROCM_VER}" -q 2>&1 | tail -3 >&2
176+
# Build list of ROCm versions to try (detected → step down → previous major)
177+
ROCM_MAJOR=$(echo "$ROCM_VER" | cut -d. -f1)
178+
ROCM_MINOR=$(echo "$ROCM_VER" | cut -d. -f2)
179+
ROCM_CANDIDATES="$ROCM_VER"
180+
m=$((ROCM_MINOR - 1))
181+
while [ "$m" -ge 0 ]; do
182+
ROCM_CANDIDATES="$ROCM_CANDIDATES ${ROCM_MAJOR}.${m}"
183+
m=$((m - 1))
184+
done
185+
# Also try previous major version (e.g., 6.4, 6.2 if on 7.x)
186+
prev_major=$((ROCM_MAJOR - 1))
187+
for pm in 4 3 2 1 0; do
188+
ROCM_CANDIDATES="$ROCM_CANDIDATES ${prev_major}.${pm}"
189+
done
190+
191+
# Phase 1: Try each candidate until PyTorch installs successfully
192+
TORCH_INSTALLED=false
193+
for ver in $ROCM_CANDIDATES; do
194+
log "Trying PyTorch for ROCm $ver ..."
195+
if "$PIP" install torch torchvision --index-url "https://download.pytorch.org/whl/rocm${ver}" -q 2>&1; then
196+
log "Installed PyTorch with ROCm $ver support"
197+
TORCH_INSTALLED=true
198+
break
199+
fi
200+
done
201+
202+
if [ "$TORCH_INSTALLED" = false ]; then
203+
log "WARNING: No PyTorch ROCm wheels found, installing CPU PyTorch from PyPI"
204+
"$PIP" install torch torchvision -q 2>&1 | tail -3 >&2
205+
fi
179206

180207
# Phase 2: remaining packages (ultralytics, onnxruntime-rocm, etc.)
181208
"$PIP" install ultralytics onnxruntime-rocm 'onnx>=1.12.0,<2.0.0' 'onnxslim>=0.1.71' \

0 commit comments

Comments
 (0)