Auto-install cupy and gdown on first node load

Detects missing deps when ComfyUI imports the node and installs
them automatically via pip. No manual steps needed in Docker.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-12 18:43:29 +01:00
parent d44885252f
commit 2c84b47590

View File

@@ -1,3 +1,35 @@
import subprocess
import sys
import logging
logger = logging.getLogger("BIM-VFI")
def _auto_install_deps():
"""Auto-install missing dependencies on first load."""
# gdown
try:
import gdown # noqa: F401
except ImportError:
logger.info("[BIM-VFI] Installing gdown...")
subprocess.check_call([sys.executable, "-m", "pip", "install", "gdown"])
# cupy
try:
import cupy # noqa: F401
except ImportError:
try:
import torch
major = int(torch.version.cuda.split(".")[0])
cupy_pkg = f"cupy-cuda{major}x"
logger.info(f"[BIM-VFI] Installing {cupy_pkg} (CUDA {torch.version.cuda})...")
subprocess.check_call([sys.executable, "-m", "pip", "install", cupy_pkg])
except Exception as e:
logger.warning(f"[BIM-VFI] Could not auto-install cupy: {e}")
_auto_install_deps()
from .nodes import LoadBIMVFIModel, BIMVFIInterpolate
NODE_CLASS_MAPPINGS = {