fix(zerogpu): patch comfy/model_management.py for is_integrated compatibility in setup.py
Browse files120 unmodified lines121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158120 unmodified lines
print(f"✅ Current working directory is: {os.getcwd()}")
# [ZeroGPU / Upstream ComfyUI Compatibility]
# Guard against ComfyUI PR #16746 is_integrated attribute check crash under ZeroGPU SimpleNamespace
try:
import torch
if hasattr(torch, "cuda") and hasattr(torch.cuda, "get_device_properties"):
_orig_gdp = torch.cuda.get_device_properties
def _safe_gdp(*args, **kwargs):
p = _orig_gdp(*args, **kwargs)
if not hasattr(p, "is_integrated"):
try:
p.is_integrated = False
except Exception:
pass
return p
torch.cuda.get_device_properties = _safe_gdp
except Exception:
pass
mm_path = os.path.join(APP_DIR, "comfy", "model_management.py")
if os.path.exists(mm_path):
try:
with open(mm_path, "r", encoding="utf-8") as f:
mm_code = f.read()
unsafe_check = "bool(torch.cuda.get_device_properties(device).is_integrated)"
safe_check = "bool(getattr(torch.cuda.get_device_properties(device), 'is_integrated', False))"
if unsafe_check in mm_code:
with open(mm_path, "w", encoding="utf-8") as f:
f.write(mm_code.replace(unsafe_check, safe_check))
print("🛡️ [Setup] Patched comfy/model_management.py for safe is_integrated attribute access.")
except Exception as e:
print(f"⚠️ [Setup] Failed to patch comfy/model_management.py: {e}")
import comfy.model_management
print("--- Environment Ready ---")
comfy_integration/setup.py+32