comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
56.63k stars 6.01k forks source link

Error occurred when executing KSampler: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights' what's wrong? thankU #3100

Open Tbler opened 7 months ago

Tbler commented 7 months ago

Error occurred when executing KSampler: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights' what's wrong? thankU 微信截图_20240321174851

huanhuachenfeng commented 7 months ago
Error occurred when executing KSampler:

ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'

File "E:\Comfyui\ComfyUI\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\execution.py", line 74, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\nodes.py", line 1369, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\nodes.py", line 1339, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample
return original_sample(*args, **kwargs) # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 346, in motion_sample
latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\utils_model.py", line 360, in wrapped_function
return function_to_wrap(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\comfy\sample.py", line 93, in sample
real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\comfy\sample.py", line 86, in prepare_sampling
comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory)
File "E:\Comfyui\ComfyUI\comfy\model_management.py", line 436, in load_models_gpu
cur_loaded_model = loaded_model.model_load(lowvram_model_memory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\Comfyui\ComfyUI\comfy\model_management.py", line 302, in model_load
self.model_unload()
File "E:\Comfyui\ComfyUI\comfy\model_management.py", line 312, in model_unload
self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights)
huanhuachenfeng commented 7 months ago

I had the same problem

huanhuachenfeng commented 7 months ago

This problem was resolved by re-cloning AnimateDiff. (Delete AnimateDiff folder, reinstall, remember to back up the model)

huanhuachenfeng commented 7 months ago

git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved

AugmentedRealityCat commented 7 months ago

This solution did not work for me. I have the same problem but reinstalling AnimateDiff-Evolved hasn't solved anything. - I still get the same error message after doing it.

EDIT: my problem was solved by removing AnimateDiff-LCM, and by installing the latest version of AnimateDiff-Evolved. Big thanks to @Kosinkadink for his precious help.

williamfang commented 7 months ago

This problem was resolved by re-cloning AnimateDiff. (Delete AnimateDiff folder, reinstall, remember to back up the model) Thanks!!! This problem was resolved.

AugmentedRealityCat commented 7 months ago

EDIT: my problem was solved by removing AnimateDiff-LCM.

Just in case there might be a clue in there, here is my own log for this problem after trying to fix it by deleting and then git-cloning AnimateDiff-Evolved:


!!! Exception during processing !!!
Traceback (most recent call last):
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 299, in model_load
    self.real_model = self.model.patch_model(device_to=patch_model_to, patch_weights=load_weights)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ModelPatcherAndInjector.patch_model() got an unexpected keyword argument 'patch_weights'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1369, in sample
    return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\nodes.py", line 1339, in common_ksampler
    samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\Comfyui-StableSR-main\nodes.py", line 69, in hook_sample
    return original_sample(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 9, in informative_sample
    return original_sample(*args, **kwargs)  # This code helps interpret error messages that occur within exceptions but does not have any impact on other operations.
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\sampling.py", line 334, in motion_sample
    latents = wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateLCM\animatediff\utils_model.py", line 272, in wrapped_function
    return function_to_wrap(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 267, in motion_sample
    return orig_comfy_sample(model, noise, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 93, in sample
    real_model, positive_copy, negative_copy, noise_mask, models = prepare_sampling(model, noise.shape, positive, negative, noise_mask)
                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\sample.py", line 86, in prepare_sampling
    comfy.model_management.load_models_gpu([model] + models, model.memory_required([noise_shape[0] * 2] + list(noise_shape[1:])) + inference_memory)
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 436, in load_models_gpu
    cur_loaded_model = loaded_model.model_load(lowvram_model_memory)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 302, in model_load
    self.model_unload()
  File "D:\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 312, in model_unload
    self.model.unpatch_model(self.model.offload_device, unpatch_weights=unpatch_weights)
TypeError: ModelPatcherAndInjector.unpatch_model() got an unexpected keyword argument 'unpatch_weights'
AugmentedRealityCat commented 7 months ago

Looks like it's related to this update from yesterday:

https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved/commit/ab156a380fc5ac49ed92af5940f05942ce596296

EDIT: if after installing that update, which is in fact the solution to the problem described in this thread, you are still getting a similar error message, then look for AnimateDiff-LCM in your custom nodes folder, and remove it if it's present. You don't need that anymore, and its presence prevents the new version of AnimateDiff-Evolved from working properly.

You can click the link just below this reply to have more info if you need any.

Kosinkadink commented 7 months ago

This was already fixed yesterday - just pull the latest version of AnimateDiff-Evolved. If it still doesn't work, that means whatever method you tried to use to update AnimateDiff-Evolved failed, and you should try again. A manual git pull inside the AnimateDiff-Evolved directory would work too if ComfyUI-Manager is not working properly for you.

The commit you linked in AnimateDiff-Evolved is the fix I pushed up - getting that error now means your AnimateDiff-Evolved is not up to date.

Tbler commented 7 months ago

This was already fixed yesterday - just pull the latest version of AnimateDiff-Evolved. If it still doesn't work, that means whatever method you tried to use to update AnimateDiff-Evolved failed, and you should try again. A manual git pull inside the AnimateDiff-Evolved directory would work too if ComfyUI-Manager is not working properly for you.

The commit you linked in AnimateDiff-Evolved is the fix I pushed up - getting that error now means your AnimateDiff-Evolved is not up to date.

![Uploading 微信截图_20240321174851.png…]()

Tbler commented 7 months ago

This was already fixed yesterday - just pull the latest version of AnimateDiff-Evolved. If it still doesn't work, that means whatever method you tried to use to update AnimateDiff-Evolved failed, and you should try again. A manual git pull inside the AnimateDiff-Evolved directory would work too if ComfyUI-Manager is not working properly for you.

The commit you linked in AnimateDiff-Evolved is the fix I pushed up - getting that error now means your AnimateDiff-Evolved is not up to date.

Still wrong 微信截图_20240321174851

Kosinkadink commented 7 months ago

If you get the error, that means it didn't update on your end. Or, as listed in my previous comment, you have more than one instance of AnimateDiff-Evolved (or Unnecessary AnimateLCM).

Show a screenshot of the entirety of your custom_nodes directory, and take a screenshot of around line 69 of custom_nodes/ComfyUI-AnimateDiff-Evolved/animatediff/model_injection.py

Here is what it should look like, as you can see, unpatch_weights is accounted for for days now: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved/blob/main/animatediff/model_injection.py#L69

Tbler commented 7 months ago

If you get the error, that means it didn't update on your end. Or, as listed in my previous comment, you have more than one instance of AnimateDiff-Evolved (or Unnecessary AnimateLCM).

Show a screenshot of the entirety of your custom_nodes directory, and take a screenshot of around line 69 of custom_nodes/ComfyUI-AnimateDiff-Evolved/animatediff/model_injection.py

Here is what it should look like, as you can see, unpatch_weights is accounted for for days now: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved/blob/main/animatediff/model_injection.py#L69

I'm sorry, I'm a beginner, not just a beginner at comfyui, but python has never been touched before, it's a completely new field, and I don't speak English very well, basically rely on translation, so most of it can't be understood I've tried a lot of things over and over again, and I don't know which one I've done yet, but now I've run through, thank you very much

giusparsifal commented 6 months ago

This solution did not work for me. I have the same problem but reinstalling AnimateDiff-Evolved hasn't solved anything. - I still get the same error message after doing it.

EDIT: my problem was solved by removing AnimateDiff-LCM, and by installing the latest version of AnimateDiff-Evolved. Big thanks to @Kosinkadink for his precious help.

Hello, I can't find AnimateDiff-LCM, I just delete AnimateDiff folder, where I can find it? Thanks.

Edit: this is the result of search of LCM in my ComfyUI directory LCM

luck54321 commented 2 months ago

感谢@giusparsifal 你的教程!