Make ComfyUI PyTorch versions dynamic from upstream README

Instead of hardcoding CUDA/ROCm/XPU versions, now dynamically extracts
the recommended PyTorch wheel URLs from ComfyUI's README.md at install time.

Benefits:
- Automatically stays up-to-date with upstream recommendations
- No manual updates needed when ComfyUI changes PyTorch versions
- Fallback to known-good versions (cu130, rocm6.4, xpu) if fetch fails

Implementation:
- Fetches https://raw.githubusercontent.com/comfyanonymous/ComfyUI/master/README.md
- Parses stable (non-nightly) pip install commands with regex
- Gracefully degrades to hardcoded fallbacks on network/parse errors
This commit is contained in:
MickLesk
2026-02-07 18:03:16 +01:00
parent c8dc7f2196
commit 87324564c6
+27 -3
View File
@@ -36,27 +36,51 @@ PYTHON_VERSION="3.12" setup_uv
fetch_and_deploy_gh_release "ComfyUI" "comfyanonymous/ComfyUI" "tarball" "latest" "/opt/ComfyUI"
msg_info "Python dependencies"
# Extract PyTorch installation URLs from ComfyUI README for latest versions
# Fallback to hardcoded values if extraction fails
pytorch_nvidia_url="https://download.pytorch.org/whl/cu130"
pytorch_amd_url="https://download.pytorch.org/whl/rocm6.4"
pytorch_intel_url="https://download.pytorch.org/whl/xpu"
if command -v curl >/dev/null 2>&1; then
readme_content=$(curl -fsSL "https://raw.githubusercontent.com/comfyanonymous/ComfyUI/master/README.md" 2>/dev/null || true)
if [[ -n "$readme_content" ]]; then
# Extract NVIDIA CUDA URL (looking for stable, not nightly)
nvidia_url=$(echo "$readme_content" | grep -oP 'pip install.*?--extra-index-url\s+\Khttps://download\.pytorch\.org/whl/cu\d+' | head -1 || true)
[[ -n "$nvidia_url" ]] && pytorch_nvidia_url="$nvidia_url"
# Extract AMD ROCm URL (stable version, not nightly)
amd_url=$(echo "$readme_content" | grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/rocm[\d.]+' | grep -v 'nightly' | head -1 || true)
[[ -n "$amd_url" ]] && pytorch_amd_url="$amd_url"
# Extract Intel XPU URL
intel_url=$(echo "$readme_content" | grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/xpu' | head -1 || true)
[[ -n "$intel_url" ]] && pytorch_intel_url="$intel_url"
fi
fi
$STD uv venv "/opt/ComfyUI/venv"
if [[ "${comfyui_gpu_type,,}" == "nvidia" ]]; then
$STD uv pip install \
torch \
torchvision \
torchaudio \
--extra-index-url "https://download.pytorch.org/whl/cu130" \
--extra-index-url "$pytorch_nvidia_url" \
--python="/opt/ComfyUI/venv/bin/python"
elif [[ "${comfyui_gpu_type,,}" == "amd" ]]; then
$STD uv pip install \
torch \
torchvision \
torchaudio \
--index-url "https://download.pytorch.org/whl/rocm6.4" \
--index-url "$pytorch_amd_url" \
--python="/opt/ComfyUI/venv/bin/python"
elif [[ "${comfyui_gpu_type,,}" == "intel" ]]; then
$STD uv pip install \
torch \
torchvision \
torchaudio \
--index-url "https://download.pytorch.org/whl/xpu" \
--index-url "$pytorch_intel_url" \
--python="/opt/ComfyUI/venv/bin/python"
fi
$STD uv pip install -r "/opt/ComfyUI/requirements.txt" --python="/opt/ComfyUI/venv/bin/python"