fix(zerogpu): patch comfy/model_management.py for is_integrated compatibility in setup.py
Browse files- comfy_integration/setup.py +32 -0
comfy_integration/setup.py
CHANGED
|
@@ -121,6 +121,38 @@ def initialize_comfyui():
|
|
| 121 |
|
| 122 |
print(f"✅ Current working directory is: {os.getcwd()}")
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
import comfy.model_management
|
| 125 |
print("--- Environment Ready ---")
|
| 126 |
|
|
|
|
| 121 |
|
| 122 |
print(f"✅ Current working directory is: {os.getcwd()}")
|
| 123 |
|
| 124 |
+
# [ZeroGPU / Upstream ComfyUI Compatibility]
|
| 125 |
+
# Guard against ComfyUI PR #16746 is_integrated attribute check crash under ZeroGPU SimpleNamespace
|
| 126 |
+
try:
|
| 127 |
+
import torch
|
| 128 |
+
if hasattr(torch, "cuda") and hasattr(torch.cuda, "get_device_properties"):
|
| 129 |
+
_orig_gdp = torch.cuda.get_device_properties
|
| 130 |
+
def _safe_gdp(*args, **kwargs):
|
| 131 |
+
p = _orig_gdp(*args, **kwargs)
|
| 132 |
+
if not hasattr(p, "is_integrated"):
|
| 133 |
+
try:
|
| 134 |
+
p.is_integrated = False
|
| 135 |
+
except Exception:
|
| 136 |
+
pass
|
| 137 |
+
return p
|
| 138 |
+
torch.cuda.get_device_properties = _safe_gdp
|
| 139 |
+
except Exception:
|
| 140 |
+
pass
|
| 141 |
+
|
| 142 |
+
mm_path = os.path.join(APP_DIR, "comfy", "model_management.py")
|
| 143 |
+
if os.path.exists(mm_path):
|
| 144 |
+
try:
|
| 145 |
+
with open(mm_path, "r", encoding="utf-8") as f:
|
| 146 |
+
mm_code = f.read()
|
| 147 |
+
unsafe_check = "bool(torch.cuda.get_device_properties(device).is_integrated)"
|
| 148 |
+
safe_check = "bool(getattr(torch.cuda.get_device_properties(device), 'is_integrated', False))"
|
| 149 |
+
if unsafe_check in mm_code:
|
| 150 |
+
with open(mm_path, "w", encoding="utf-8") as f:
|
| 151 |
+
f.write(mm_code.replace(unsafe_check, safe_check))
|
| 152 |
+
print("🛡️ [Setup] Patched comfy/model_management.py for safe is_integrated attribute access.")
|
| 153 |
+
except Exception as e:
|
| 154 |
+
print(f"⚠️ [Setup] Failed to patch comfy/model_management.py: {e}")
|
| 155 |
+
|
| 156 |
import comfy.model_management
|
| 157 |
print("--- Environment Ready ---")
|
| 158 |
|