From f87c62c76318fa735cf9c541a249035b38213ef9 Mon Sep 17 00:00:00 2001 From: Level Pixel Dev Date: Thu, 29 May 2025 22:43:04 +0600 Subject: [PATCH] Hotfix for onnxruntime --- install_init.py | 16 ++++++++++++---- pyproject.toml | 5 +++-- requirements.txt | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/install_init.py b/install_init.py index 1abcb53..892bca9 100644 --- a/install_init.py +++ b/install_init.py @@ -338,10 +338,18 @@ def is_installed(pkg_name: str, min_version: str = '') -> bool: return False def install(pkg_spec: str): - subprocess.check_call([sys.executable, '-m', 'pip', 'install', pkg_spec]) + try: + subprocess.check_call([sys.executable, '-m', 'pip', 'install', pkg_spec]) + except subprocess.CalledProcessError as e: + print(f"Failed to install {pkg_spec}: {e}") + raise def uninstall(pkg: str): - subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', '-y', pkg]) + try: + subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', '-y', pkg]) + except subprocess.CalledProcessError as e: + print(f"Failed to uninstall {pkg}: {e}") + raise def install_onnxruntime(): import torch @@ -349,7 +357,7 @@ def install_onnxruntime(): print(f"Found NVIDIA GPU: {gpu}") if gpu: if is_installed('onnxruntime'): - #uninstall("onnxruntime") + uninstall("onnxruntime") print(f"LP >>> Your python has the 'onnxruntime' library installed, although your computer supports 'onnxruntime-gpu'.") print(f"LP >>> Solution: If other node packages do not use the 'onnxruntime' library, then remove the 'onnxruntime' library for your python.") print(f"LP >>> Close ComfyUI and run the script at .\\ComfyUI\\custom_nodes\\ComfyUI-LevelPixel-Advanced\\scripts\\remove_onnxruntime.bat") @@ -357,7 +365,7 @@ def install_onnxruntime(): install("onnxruntime-gpu>=1.22") else: if is_installed('onnxruntime-gpu'): - #uninstall("onnxruntime-gpu") + uninstall("onnxruntime-gpu") print(f"LP >>> Your python has the 'onnxruntime-gpu' library installed, but you don't have a GPU.") print(f"LP >>> Solution: If other node packages do not use the 'onnxruntime-gpu' library, then remove the 'onnxruntime-gpu' library for your python.") print(f"LP >>> Close ComfyUI and run the script at .\\ComfyUI\\custom_nodes\\ComfyUI-LevelPixel-Advanced\\scripts\\remove_onnxruntime.bat") diff --git a/pyproject.toml b/pyproject.toml index 16b4396..ae60489 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-levelpixel-advanced" description = "Advanced nodes of the Level Pixel company (aka levelpixel, LP). Includes convenient advanced nodes for working with LLM и VLM models (LLaVa, Multimodal Generator) with GGUF format. Qwen2.5-VL and Qwen2.5 supported, based on llama-mtmd. Also included is a node for the RAM model. Nodes have the ability to automatically unload models from VRAM. This package also includes Autotagger (WD), Image Remove Background (based on RMBG-2.0, on BiRefNet, on BiRefNet-HR-Matter, on RemBG). Repository: https://github.com/LevelPixel/ComfyUI-LevelPixel-Advanced" -version = "1.2.4" +version = "1.2.5" license = { file = "LICENSE" } dependencies = [ "torch>=2.0.1", @@ -19,7 +19,8 @@ dependencies = [ "rembg>=2.0.66", "diskcache>=5.6.1", "jinja2>=2.11.3", - "typing-extensions>=4.5.0" ] + "typing-extensions>=4.5.0", + "onnxruntime-gpu>=1.22" ] [project.urls] Repository = "https://github.com/LevelPixel/ComfyUI-LevelPixel-Advanced" diff --git a/requirements.txt b/requirements.txt index 64340de..b58d951 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,5 @@ matplotlib diskcache>=5.6.1 jinja2>=2.11.3 typing-extensions>=4.5.0 +onnxruntime-gpu>=1.22 ram @ git+https://github.com/xinyu1205/recognize-anything.git