mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-07 22:03:26 +01:00
Optimize PyTorch URL extraction: only parse for selected GPU type
Instead of extracting all three GPU URLs unconditionally, now only extracts the URL for the user's selected GPU type. More efficient: - Only one grep execution instead of three - Less code duplication - Faster execution
This commit is contained in:
@@ -36,48 +36,43 @@ 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 [[ -f "/opt/ComfyUI/README.md" ]]; then
|
||||
# Extract NVIDIA CUDA URL (looking for stable, not nightly)
|
||||
nvidia_url=$(grep -oP 'pip install.*?--extra-index-url\s+\Khttps://download\.pytorch\.org/whl/cu\d+' /opt/ComfyUI/README.md | head -1 || true)
|
||||
[[ -n "$nvidia_url" ]] && pytorch_nvidia_url="$nvidia_url"
|
||||
|
||||
# Extract AMD ROCm URL (stable version, not nightly)
|
||||
amd_url=$(grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/rocm[\d.]+' /opt/ComfyUI/README.md | grep -v 'nightly' | head -1 || true)
|
||||
[[ -n "$amd_url" ]] && pytorch_amd_url="$amd_url"
|
||||
|
||||
# Extract Intel XPU URL
|
||||
intel_url=$(grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/xpu' /opt/ComfyUI/README.md | head -1 || true)
|
||||
[[ -n "$intel_url" ]] && pytorch_intel_url="$intel_url"
|
||||
fi
|
||||
|
||||
$STD uv venv "/opt/ComfyUI/venv"
|
||||
|
||||
if [[ "${comfyui_gpu_type,,}" == "nvidia" ]]; then
|
||||
pytorch_url="https://download.pytorch.org/whl/cu130"
|
||||
if [[ -f "/opt/ComfyUI/README.md" ]]; then
|
||||
extracted=$(grep -oP 'pip install.*?--extra-index-url\s+\Khttps://download\.pytorch\.org/whl/cu\d+' /opt/ComfyUI/README.md | head -1 || true)
|
||||
[[ -n "$extracted" ]] && pytorch_url="$extracted"
|
||||
fi
|
||||
$STD uv pip install \
|
||||
torch \
|
||||
torchvision \
|
||||
torchaudio \
|
||||
--extra-index-url "$pytorch_nvidia_url" \
|
||||
--extra-index-url "$pytorch_url" \
|
||||
--python="/opt/ComfyUI/venv/bin/python"
|
||||
elif [[ "${comfyui_gpu_type,,}" == "amd" ]]; then
|
||||
pytorch_url="https://download.pytorch.org/whl/rocm6.4"
|
||||
if [[ -f "/opt/ComfyUI/README.md" ]]; then
|
||||
extracted=$(grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/rocm[\d.]+' /opt/ComfyUI/README.md | grep -v 'nightly' | head -1 || true)
|
||||
[[ -n "$extracted" ]] && pytorch_url="$extracted"
|
||||
fi
|
||||
$STD uv pip install \
|
||||
torch \
|
||||
torchvision \
|
||||
torchaudio \
|
||||
--index-url "$pytorch_amd_url" \
|
||||
--index-url "$pytorch_url" \
|
||||
--python="/opt/ComfyUI/venv/bin/python"
|
||||
elif [[ "${comfyui_gpu_type,,}" == "intel" ]]; then
|
||||
pytorch_url="https://download.pytorch.org/whl/xpu"
|
||||
if [[ -f "/opt/ComfyUI/README.md" ]]; then
|
||||
extracted=$(grep -oP 'pip install.*?--index-url\s+\Khttps://download\.pytorch\.org/whl/xpu' /opt/ComfyUI/README.md | head -1 || true)
|
||||
[[ -n "$extracted" ]] && pytorch_url="$extracted"
|
||||
fi
|
||||
$STD uv pip install \
|
||||
torch \
|
||||
torchvision \
|
||||
torchaudio \
|
||||
--index-url "$pytorch_intel_url" \
|
||||
--index-url "$pytorch_url" \
|
||||
--python="/opt/ComfyUI/venv/bin/python"
|
||||
fi
|
||||
$STD uv pip install -r "/opt/ComfyUI/requirements.txt" --python="/opt/ComfyUI/venv/bin/python"
|
||||
|
||||
Reference in New Issue
Block a user