Kosinkadink / ComfyUI-AnimateDiff-Evolved

Improved AnimateDiff for ComfyUI and Advanced Sampling Support
Apache License 2.0
2.37k stars 180 forks source link

RuntimeError: You can't move a model that has some modules offloaded to cpu or disk #225

Closed aabbene09 closed 7 months ago

aabbene09 commented 7 months ago

Was working yesterday, saw was a new update for lcm_lora. I reinstalled everything including ComfyUI, Manager, AnimateDiff Evolved, Video Helper Suite, using 1.5 model, Loading the default example text2img workflow, AnimateDiff loader, after Ksampler, at VaeDecoder:

Error occurred when executing VAEDecode:

You can't move a model that has some modules offloaded to cpu or disk.

File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(*slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 267, in decode return (vae.decode(samples["samples"]), ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 226, in decode model_management.load_models_gpu([self.patcher], memory_required=memory_used) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 388, in load_models_gpu free_memory(total_memory_required[device] 1.3 + extra_mem, device, models_already_loaded) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 340, in free_memory m.model_unload() File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 311, in model_unload self.model.unpatch_model(self.model.offload_device) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\model_injection.py", line 49, in unpatch_model self.eject_model(device_to=device_to) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\model_injection.py", line 62, in eject_model self.motion_model.model.to(device_to) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\python_embeded\Lib\site-packages\accelerate\big_modeling.py", line 415, in wrapper raise RuntimeError("You can't move a model that has some modules offloaded to cpu or disk.")

Kosinkadink commented 7 months ago

Thanks for the report, I now pushed a new update that should stop that error from being thrown - can you update AnimateDiff-Evolved, and see if the issue is fixed?

aabbene09 commented 7 months ago

Just updated and:

Error occurred when executing VAEDecode:

You can't move a model that has some modules offloaded to cpu or disk.

File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(*slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\nodes.py", line 267, in decode return (vae.decode(samples["samples"]), ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 226, in decode model_management.load_models_gpu([self.patcher], memory_required=memory_used) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 388, in load_models_gpu free_memory(total_memory_required[device] 1.3 + extra_mem, device, models_already_loaded) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 340, in free_memory m.model_unload() File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 312, in model_unload self.model.model_patches_to(self.model.offload_device) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\model_injection.py", line 38, in model_patches_to self.motion_model.model.to(device) File "C:\stb\new_ComfyUI_windows_portable_nvidia_cu121_or_cpu\ComfyUI_windows_portable\python_embeded\Lib\site-packages\accelerate\big_modeling.py", line 415, in wrapper raise RuntimeError("You can't move a model that has some modules offloaded to cpu or disk.")

Above was tested with default Txt2Img workflow as well as with LCM_lora and discrete sampler plugged in.

Kosinkadink commented 7 months ago

Alrighty, I pushed out a new update that should properly catch that error in the places where it can happen. Let me know if that fixes it, or if there is a new place it creeps up now!

aabbene09 commented 7 months ago

Bingo! Seems resolved. You work fast!