Suzie1 / ComfyUI_Comfyroll_CustomNodes

Custom nodes for SDXL and SD1.5 including Multi-ControlNet, LoRA, Aspect Ratio, Process Switches, and many more nodes.
https://civitai.com/models/183551/comfyui-comfyroll-custom-nodes
630 stars 85 forks source link

AttributeError: 'ImageModelDescriptor' object has no attribute 'cpu' #172

Open WangGosh opened 4 months ago

WangGosh commented 4 months ago

I deployed ComfyUI on the DSW server of Alibaba Cloud. When I tried to zoom in with the enlarged model, it displayed this error image image image

WangGosh commented 4 months ago

pytorch2.1.2tensorflow2.14.0-gpu-py310-cu121-ubuntu22.04 This is my system environment

Moxie1776 commented 4 months ago

I stopped using a1111 for a few months. When I tried it today again today, I'm getting the same error...

speters commented 3 months ago

Can confirm this when trying out the DemonCore Workflow from Civitai, which depends on these nodes for upscaling.

After having searched and found a hint on stackoverflow, I made a desperate attempt that finally worked:

diff --git a/nodes/functions_upscale.py b/nodes/functions_upscale.py
index 2c25f03..a6c748c 100644
--- a/nodes/functions_upscale.py
+++ b/nodes/functions_upscale.py
@@ -54,7 +54,8 @@ def upscale_with_model(upscale_model, image):
             if tile < 128:
                 raise e

-    upscale_model.cpu()
+    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
+    upscale_model.to(device)
     s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0)
     return s
DGdev91 commented 2 months ago

Can confirm this when trying out the DemonCore Workflow from Civitai, which depends on these nodes for upscaling.

After having searched and found a hint on stackoverflow, I made a desperate attempt that finally worked:

diff --git a/nodes/functions_upscale.py b/nodes/functions_upscale.py
index 2c25f03..a6c748c 100644
--- a/nodes/functions_upscale.py
+++ b/nodes/functions_upscale.py
@@ -54,7 +54,8 @@ def upscale_with_model(upscale_model, image):
             if tile < 128:
                 raise e

-    upscale_model.cpu()
+    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
+    upscale_model.to(device)
     s = torch.clamp(s.movedim(-3,-1), min=0, max=1.0)
     return s

Nice, works great for me. have you already made a PR for this fix?

speters commented 2 months ago

No, I didn't make a PR. The @Suzie1 account seems pretty inactive since Feb'24, so I didn't bother.