- runpod-install.sh: Single-command installer for all three projects (clones repos, installs requirements, auto-detects CUDA version) - install.py: Now gracefully handles CUDA 12.8 vs 13+ (TensorRT only on CUDA 13+, falls back to Real-ESRGAN on 12.8) - Clear logging of which upscaler path is being used Future RunPod pods can now just run: bash custom_nodes/ComfyUI-Goofer/runpod-install.sh Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
3.3 KiB
Python
89 lines
3.3 KiB
Python
"""
|
|
ComfyUI-Goofer auto-installer.
|
|
|
|
ComfyUI-Manager executes this file when the node pack is first loaded.
|
|
It installs base requirements and, on Linux with NVIDIA GPUs, also
|
|
installs torch-tensorrt from the correct CUDA-versioned wheel index
|
|
so the TensorRT upscaler path activates instead of falling back to
|
|
plain Real-ESRGAN.
|
|
|
|
Author: Jeffrey A. Brick
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
import platform
|
|
import os
|
|
import shutil
|
|
|
|
|
|
def _pip(*args):
|
|
"""Run pip in the current Python environment."""
|
|
subprocess.check_call([sys.executable, "-m", "pip", *args])
|
|
|
|
|
|
def _get_cuda_version():
|
|
"""Detect CUDA toolkit version from nvcc. Returns e.g. '128' or None."""
|
|
nvcc = shutil.which("nvcc")
|
|
if not nvcc:
|
|
# Check common CUDA install paths
|
|
for path in ["/usr/local/cuda/bin/nvcc", "/usr/bin/nvcc"]:
|
|
if os.path.isfile(path):
|
|
nvcc = path
|
|
break
|
|
if not nvcc:
|
|
return None
|
|
try:
|
|
out = subprocess.check_output([nvcc, "--version"], text=True)
|
|
# Parse "release 12.8" -> "128"
|
|
for line in out.splitlines():
|
|
if "release" in line.lower():
|
|
parts = line.split("release")[-1].strip().split(",")[0].strip()
|
|
major, minor = parts.split(".")[:2]
|
|
return f"{major}{minor}"
|
|
except Exception:
|
|
pass
|
|
return None
|
|
|
|
|
|
def install():
|
|
print("[ComfyUI-Goofer] Installing base requirements...")
|
|
req_file = os.path.join(os.path.dirname(__file__), "requirements.txt")
|
|
_pip("install", "-r", req_file)
|
|
|
|
# On Linux with NVIDIA GPU, install TensorRT with correct CUDA index if CUDA 13+
|
|
if platform.system() == "Linux":
|
|
cuda_ver = _get_cuda_version()
|
|
if cuda_ver:
|
|
print(f"[ComfyUI-Goofer] Linux detected, CUDA {cuda_ver}")
|
|
|
|
# TensorRT requires CUDA 13+
|
|
if cuda_ver.startswith("13") or cuda_ver.startswith("14"):
|
|
index_url = f"https://download.pytorch.org/whl/cu{cuda_ver}"
|
|
print(f"[ComfyUI-Goofer] Installing torch-tensorrt from {index_url}")
|
|
print("[ComfyUI-Goofer] (TensorRT enables NVIDIA tensor core optimization for Real-ESRGAN)")
|
|
try:
|
|
_pip(
|
|
"install", "torch-tensorrt", "torchaudio",
|
|
"--extra-index-url", index_url,
|
|
)
|
|
print("[ComfyUI-Goofer] ✓ TensorRT installed — tensor core acceleration enabled.")
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"[ComfyUI-Goofer] WARNING: torch-tensorrt install failed: {e}")
|
|
print("[ComfyUI-Goofer] Upscaler will use standard Real-ESRGAN (still NVIDIA GPU-accelerated).")
|
|
else:
|
|
print(f"[ComfyUI-Goofer] CUDA {cuda_ver} detected (CUDA 12.x)")
|
|
print("[ComfyUI-Goofer] TensorRT requires CUDA 13+, skipping.")
|
|
print("[ComfyUI-Goofer] Upscaler will use Real-ESRGAN (standard NVIDIA CUDA acceleration).")
|
|
else:
|
|
print("[ComfyUI-Goofer] No CUDA toolkit found (nvcc missing).")
|
|
print("[ComfyUI-Goofer] Upscaler will use Real-ESRGAN.")
|
|
else:
|
|
print("[ComfyUI-Goofer] Windows detected — using nvvfx RTX VSR (no torch-tensorrt needed).")
|
|
|
|
print("[ComfyUI-Goofer] ✓ Install complete.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
install()
|