From 1b5d7089001f09085c2ee181526ccad33b3ae26d Mon Sep 17 00:00:00 2001 From: huchukato Date: Fri, 23 Oct 2026 22:15:20 +0200 Subject: [PATCH] =?UTF-8?q?Guard=20TensorRT/polygraphy=20module=20imports?= =?UTF-8?q?=20=E2=80=94=20pack=20registers=20nodes=20even=20without=20Tens?= =?UTF-8?q?orRT,=20with=20clear=20actionable=20errors=20at=20engine=20buil?= =?UTF-8?q?d/run=20instead=20of=20failing=20to=20import=20(fixes=20'missin?= =?UTF-8?q?g=20node=20type'=20reports)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 27 ++++++++++++++++++++++++--- pyproject.toml | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 9f90f8e..bf936ca 100644 --- a/__init__.py +++ b/__init__.py @@ -6,7 +6,12 @@ import re from pathlib import Path from comfy.model_management import get_torch_device from .vfi_utilities import preprocess_frames, postprocess_frames, generate_frames_rife, logger, InterpolationStateList, infer_tiled -from .trt_utilities import Engine +try: + from .trt_utilities import Engine +except Exception as _trt_utils_err: + Engine = None + print(f"[ComfyUI-RIFE-TensorRT] trt utilities not importable ({_trt_utils_err}); " + "run 'pip install -r requirements.txt' in this folder and restart ComfyUI.") from .utilities import download_file, ColoredLogger import folder_paths import time @@ -283,9 +288,19 @@ def _setup_cuda_dll_path(): _setup_cuda_dll_path() -from polygraphy import cuda +try: + from polygraphy import cuda +except Exception as _poly_err: + cuda = None + print(f"[ComfyUI-RIFE-TensorRT] polygraphy/cuda bindings not importable ({_poly_err}); " + "run 'pip install -r requirements.txt' in this folder and restart ComfyUI.") import comfy.model_management as mm -import tensorrt +try: + import tensorrt +except ImportError: + tensorrt = None + print("[ComfyUI-RIFE-TensorRT] TensorRT not importable — nodes will register, but building/running " + "engines needs TensorRT. Run install.py (Windows: install.bat) in this folder and restart ComfyUI.") import json ENGINE_DIR = os.path.join(folder_paths.models_dir, "tensorrt", "rife") @@ -447,6 +462,9 @@ class AutoLoadRifeTensorrtModel: engine_max_batch = max(1, batch_size) engine_min_h, engine_opt_h, engine_max_h = dim_min, dim_opt, dim_max engine_min_w, engine_opt_w, engine_max_w = dim_min, dim_opt, dim_max + if tensorrt is None or Engine is None: + raise RuntimeError("[ComfyUI-RIFE-TensorRT] TensorRT or its utilities are not importable — run " + "install.py (Windows: install.bat) in the node folder, then restart ComfyUI.") tensorrt_model_path = os.path.join(tensorrt_models_dir, f"{model}_{precision}_{profile_name}_{engine_min_batch}x{engine_channel}x{engine_min_h}x{engine_min_w}_{engine_opt_batch}x{engine_channel}x{engine_opt_h}x{engine_opt_w}_{engine_max_batch}x{engine_channel}x{engine_max_h}x{engine_max_w}_{tensorrt.__version__}.trt") if not os.path.exists(tensorrt_model_path): @@ -578,6 +596,9 @@ class AutoRifeTensorrt: "output": {"shape": (1, 3, H, W)}, } + if cuda is None: + raise RuntimeError("[ComfyUI-RIFE-TensorRT] polygraphy/cuda bindings are missing — run " + "'pip install -r requirements.txt' in the node folder, then restart ComfyUI.") cudaStream = cuda.Stream() # Auto-detect CUDA graph usage based on CUDA version diff --git a/pyproject.toml b/pyproject.toml index 9200e7c..f9e37ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "Auto-TensorRT-RIFE" description = "Ultra fast video frame interpolation for ComfyUI using RIFE with TensorRT acceleration. Auto-detects CUDA version, installs matching TensorRT wheels, and downloads RIFE models automatically." -version = "1.2.4" +version = "1.2.5" license = { file = "LICENSE" } [project.urls]