From 8fe382e5ec3b5fab75aded0bad381b71ced639ff Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Fri, 27 Feb 2026 13:13:01 +0100 Subject: [PATCH] Remove auto-install of all deps except cupy Dependencies are now handled by pyproject.toml / requirements.txt via ComfyUI Manager or pip. Only cupy is auto-installed at load time since it requires matching the PyTorch CUDA version; failures produce a warning instead of crashing. Also added timm to requirements.txt. Co-Authored-By: Claude Opus 4.6 --- README.md | 19 +++++++--------- __init__.py | 56 ++++++++++++++++++++---------------------------- requirements.txt | 1 + 3 files changed, 32 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 5919c74..26fbe43 100644 --- a/README.md +++ b/README.md @@ -149,36 +149,33 @@ Same as GIMM-VFI Interpolate but processes a single segment. Same pattern as BIM ## Installation -Clone into your ComfyUI `custom_nodes/` directory: +Install from the [ComfyUI Registry](https://registry.comfy.org/) or clone into your ComfyUI `custom_nodes/` directory: ```bash cd ComfyUI/custom_nodes git clone https://github.com/Ethanfel/ComfyUI-Tween.git +pip install -r requirements.txt ``` -Dependencies (`gdown`, `cupy`, `timm`, `omegaconf`, `easydict`, `yacs`, `einops`, `huggingface_hub`) are auto-installed on first load. The correct `cupy` variant is detected from your PyTorch CUDA version. +### cupy -> **Warning:** `cupy` is a large package (~800MB) and compilation/installation can take several minutes. The first ComfyUI startup after installing this node may appear to hang while `cupy` installs in the background. Check the console log for progress. If auto-install fails (e.g. missing build tools in Docker), install manually with: -> ```bash -> pip install cupy-cuda12x # replace 12 with your CUDA major version -> ``` - -To install manually: +`cupy` is required for BIM-VFI, SGM-VFI, and GIMM-VFI (optical flow warping). It will be auto-installed on first load based on your PyTorch CUDA version. If auto-install fails, install manually: ```bash -cd ComfyUI-Tween -python install.py +pip install cupy-cuda12x # replace 12 with your CUDA major version (11 or 12) ``` ### Requirements - PyTorch with CUDA -- `cupy` (matching your CUDA version, for BIM-VFI, SGM-VFI, and GIMM-VFI) +- `cupy` (matching your CUDA version — for BIM-VFI, SGM-VFI, and GIMM-VFI) - `timm` (for EMA-VFI and SGM-VFI) - `gdown` (for BIM-VFI/EMA-VFI/SGM-VFI model auto-download) - `omegaconf`, `easydict`, `yacs`, `einops` (for GIMM-VFI) - `huggingface_hub` (for GIMM-VFI model auto-download) +All dependencies except `cupy` are listed in `pyproject.toml` and installed automatically by ComfyUI Manager or pip. + ## VRAM Guide | VRAM | Recommended settings | diff --git a/__init__.py b/__init__.py index 2981ddc..857c956 100644 --- a/__init__.py +++ b/__init__.py @@ -5,45 +5,35 @@ import logging logger = logging.getLogger("Tween") -def _auto_install_deps(): - """Auto-install missing dependencies on first load.""" - # gdown - try: - import gdown # noqa: F401 - except ImportError: - logger.info("[Tween] Installing gdown...") - subprocess.check_call([sys.executable, "-m", "pip", "install", "gdown"]) - - # timm (required for EMA-VFI's MotionFormer backbone) - try: - import timm # noqa: F401 - except ImportError: - logger.info("[Tween] Installing timm...") - subprocess.check_call([sys.executable, "-m", "pip", "install", "timm"]) - - # cupy +def _ensure_cupy(): + """Try to auto-install cupy if missing, matching the PyTorch CUDA version.""" try: import cupy # noqa: F401 + return except ImportError: - try: - import torch - major = int(torch.version.cuda.split(".")[0]) - cupy_pkg = f"cupy-cuda{major}x" - logger.info(f"[Tween] Installing {cupy_pkg} (CUDA {torch.version.cuda})...") - subprocess.check_call([sys.executable, "-m", "pip", "install", cupy_pkg]) - except Exception as e: - logger.warning(f"[Tween] Could not auto-install cupy: {e}") + pass - # GIMM-VFI dependencies - for pkg in ("omegaconf", "yacs", "easydict", "einops", "huggingface_hub"): - try: - __import__(pkg) - except ImportError: - logger.info(f"[Tween] Installing {pkg}...") - subprocess.check_call([sys.executable, "-m", "pip", "install", pkg]) + try: + import torch + if not torch.cuda.is_available() or not hasattr(torch.version, "cuda") or torch.version.cuda is None: + logger.warning( + "[Tween] CUDA not available — cupy cannot be installed. " + "SGM-VFI and GIMM-VFI require CUDA." + ) + return + major = int(torch.version.cuda.split(".")[0]) + cupy_pkg = f"cupy-cuda{major}x" + logger.info(f"[Tween] Installing {cupy_pkg} (CUDA {torch.version.cuda})...") + subprocess.check_call([sys.executable, "-m", "pip", "install", cupy_pkg]) + except Exception as e: + logger.warning( + f"[Tween] Could not auto-install cupy: {e}\n" + f"[Tween] SGM-VFI and GIMM-VFI will not work without cupy. Install manually:\n" + f"[Tween] pip install cupy-cuda12x # replace 12 with your CUDA major version" + ) -_auto_install_deps() +_ensure_cupy() from .nodes import ( LoadBIMVFIModel, BIMVFIInterpolate, BIMVFISegmentInterpolate, TweenConcatVideos, diff --git a/requirements.txt b/requirements.txt index 0a20468..8e45d1e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ gdown +timm omegaconf yacs easydict