Skip to content

Commit bbd5db6

Browse files
committed
fix(deploy): simplify ROCm install — correct packages from the start
Instead of installing wrong packages then cleaning up: - Phase 1: PyTorch from ROCm --index-url (forces ROCm build, not CUDA) - Phase 2: remaining packages incl. onnxruntime-rocm, onnx, onnxslim - YOLO_AUTOINSTALL=0 prevents ultralytics from auto-installing CPU onnxruntime Removed: pre-install onnxruntime cleanup, post-export onnxruntime cleanup (no longer needed when packages are installed correctly)
1 parent dacf7cb commit bbd5db6

File tree

1 file changed

+13
-18
lines changed
  • skills/detection/yolo-detection-2026

1 file changed

+13
-18
lines changed

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

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,28 @@ fi
160160
log "Installing dependencies from $REQ_FILE ..."
161161
emit "{\"event\": \"progress\", \"stage\": \"install\", \"message\": \"Installing $BACKEND dependencies...\"}"
162162

163-
# ROCm: remove CPU-only onnxruntime if present (it shadows onnxruntime-rocm)
164163
if [ "$BACKEND" = "rocm" ]; then
165-
if "$PIP" show onnxruntime &>/dev/null 2>&1; then
166-
log "Removing CPU-only onnxruntime to avoid shadowing onnxruntime-rocm..."
167-
"$PIP" uninstall -y onnxruntime -q 2>&1 || true
168-
fi
169-
fi
164+
# ROCm: two-phase install to get the correct packages
165+
# Phase 1: PyTorch from ROCm index (--index-url forces ROCm build, not CUDA)
166+
log "Installing PyTorch with ROCm support..."
167+
"$PIP" install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.2 -q 2>&1 | tail -3 >&2
168+
169+
# Phase 2: remaining packages (ultralytics, onnxruntime-rocm, etc.)
170+
"$PIP" install ultralytics onnxruntime-rocm 'onnx>=1.12.0,<2.0.0' 'onnxslim>=0.1.71' \
171+
'numpy>=1.24.0' 'opencv-python-headless>=4.8.0' 'Pillow>=10.0.0' -q 2>&1 | tail -3 >&2
170172

171-
"$PIP" install -r "$REQ_FILE" -q 2>&1 | tail -5 >&2
173+
# Prevent ultralytics from auto-installing CPU onnxruntime during export
174+
export YOLO_AUTOINSTALL=0
175+
else
176+
"$PIP" install -r "$REQ_FILE" -q 2>&1 | tail -5 >&2
177+
fi
172178

173179
# ─── Step 5: Pre-convert model to optimized format ───────────────────────────
174180

175181
if [ "$BACKEND" != "cpu" ] || [ -f "$SKILL_DIR/requirements_cpu.txt" ]; then
176182
log "Pre-converting model to optimized format for $BACKEND..."
177183
emit "{\"event\": \"progress\", \"stage\": \"optimize\", \"message\": \"Converting model for $BACKEND (~30-120s)...\"}"
178184

179-
# Disable ultralytics auto-install (it would re-install CPU onnxruntime)
180-
export YOLO_AUTOINSTALL=0
181-
182185
"$VENV_DIR/bin/python" -c "
183186
import sys
184187
sys.path.insert(0, '$ENV_CONFIG_DIR')
@@ -205,14 +208,6 @@ else:
205208
fi
206209
fi
207210

208-
# ROCm: final cleanup — remove CPU onnxruntime if ultralytics re-installed it
209-
if [ "$BACKEND" = "rocm" ]; then
210-
if "$PIP" show onnxruntime 2>/dev/null | grep -q "^Name: onnxruntime$"; then
211-
log "Post-export cleanup: removing CPU onnxruntime (re-installed by ultralytics)..."
212-
"$PIP" uninstall -y onnxruntime -q 2>&1 || true
213-
fi
214-
fi
215-
216211
# ─── Step 6: Verify installation ────────────────────────────────────────────
217212

218213
log "Verifying installation..."

0 commit comments

Comments
 (0)