160160log " Installing dependencies from $REQ_FILE ..."
161161emit " {\" event\" : \" progress\" , \" stage\" : \" install\" , \" message\" : \" Installing $BACKEND dependencies...\" }"
162162
163- # ROCm: remove CPU-only onnxruntime if present (it shadows onnxruntime-rocm)
164163if [ " $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
175181if [ " $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 "
183186import sys
184187sys.path.insert(0, '$ENV_CONFIG_DIR ')
@@ -205,14 +208,6 @@ else:
205208 fi
206209fi
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
218213log " Verifying installation..."
0 commit comments