Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'ModelPatcher' from 'comfy.sd' #6

Open
spacepxl opened this issue Sep 3, 2023 · 5 comments
Open

cannot import name 'ModelPatcher' from 'comfy.sd' #6

spacepxl opened this issue Sep 3, 2023 · 5 comments

Comments

@spacepxl
Copy link

spacepxl commented Sep 3, 2023

Traceback (most recent call last):
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1698, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\__init__.py", line 2, in <module>
    from .vae import VAEDecodeBatched, VAEEncodeBatched
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\vae.py", line 5, in <module>
    from .model.iter import try_get_iter
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\model\iter.py", line 4, in <module>
    from comfy.sd import ModelPatcher, CLIP, VAE
ImportError: cannot import name 'ModelPatcher' from 'comfy.sd' (C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

Cannot import C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr module for custom nodes: cannot import name 'ModelPatcher' from 'comfy.sd' (C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

comfyanonymous/ComfyUI@f92074b

Solution: modify import statements in iter.py and sample.py

iter.py, line 4:

from comfy.sd import ModelPatcher, CLIP, VAE

->

from comfy.sd import CLIP, VAE
from comfy.model_patcher import ModelPatcher

sample.py, line 9:

from comfy.sd import ModelPatcher

->

from comfy.model_patcher import ModelPatcher
@emourdavid
Copy link

Thank you. I can solve this issue right now

@Gloynus
Copy link

Gloynus commented Nov 18, 2023

It's not working.


### Loading: ComfyUI-Impact-Pack (V4.30.8)
### Loading: ComfyUI-Impact-Pack (Subpack: V0.3)
Package diffusers is already installed.
### Loading: ComfyUI-Manager (V1.0.1)
### ComfyUI Revision: 1699 [0cf4e869] | Released on '2023-11-17'
Traceback (most recent call last):
  File "D:\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1735, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr-main\__init__.py", line 3, in <module>
    from .sample import KSamplerSetting, KSamplerOverrided, KSamplerXYZ
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr-main\sample.py", line 11, in <module>
    from .model import merge2
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr-main\model\merge2.py", line 8, in <module>
    from comfy.ldm.models.diffusion.ddpm import LatentDiffusion
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\ldm\models\diffusion\ddpm.py", line 12, in <module>
    import pytorch_lightning as pl
ModuleNotFoundError: No module named 'pytorch_lightning'

Cannot import D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr-main module for custom nodes: No module named 'pytorch_lightning'
Total VRAM 12287 MB, total RAM 32617 MB
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 3060 : cudaMallocAsync
VAE dtype: torch.bfloat16
Torch version: 2.1.0+cu121
[VideoHelperSuite] - INFO - ffmpeg could not be found. Using ffmpeg from imageio-ffmpeg.
DWPose: Onnxruntime with acceleration providers detected

Import times for custom nodes:
   0.0 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Styles_CSV_Loader
   0.0 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_Noise
   0.0 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet
   0.0 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI_NestedNodeBuilder
   0.1 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-animatediff
   0.1 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved
   0.2 seconds (IMPORT FAILED): D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr-main
   0.4 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui_controlnet_aux
   0.7 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-LCM
   0.7 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Manager
   1.2 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-reactor-node
   1.7 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-VideoHelperSuite
   4.6 seconds: D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack

@emourdavid
Copy link

You use 3 commands if you uses Windows
cd D:\ComfyUI_windows_portable\ComfyUI
venv\Scripts\activate.bat
pip install pytorch_lightning

@aksoyayberk
Copy link

Traceback (most recent call last):
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1698, in load_custom_node
    module_spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\__init__.py", line 2, in <module>
    from .vae import VAEDecodeBatched, VAEEncodeBatched
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\vae.py", line 5, in <module>
    from .model.iter import try_get_iter
  File "C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr\model\iter.py", line 4, in <module>
    from comfy.sd import ModelPatcher, CLIP, VAE
ImportError: cannot import name 'ModelPatcher' from 'comfy.sd' (C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

Cannot import C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-nodes-hnmr module for custom nodes: cannot import name 'ModelPatcher' from 'comfy.sd' (C:\Users\****\Desktop\ComfyUI_windows_portable\ComfyUI\comfy\sd.py)

comfyanonymous/ComfyUI@f92074b

Solution: modify import statements in iter.py and sample.py

iter.py, line 4:

from comfy.sd import ModelPatcher, CLIP, VAE

->

from comfy.sd import CLIP, VAE
from comfy.model_patcher import ModelPatcher

sample.py, line 9:

from comfy.sd import ModelPatcher

->

from comfy.model_patcher import ModelPatcher

Thanks for the solution!
I wonder why this has not applied to the main branch yet..

@aksoyayberk
Copy link

Please check https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr as it includes some important fixes on top of this original repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants