Skip to content

Controlnet inference out of memory #19

@zhangp365

Description

@zhangp365

After Loading Magic Animate model, Magic Animate node starts to run. Then there is a Exception.

Error occurred when executing MagicAnimate:

Allocation on device 0 would exceed allowed memory. (out of memory)
Currently allocated : 6.82 GiB
Requested : 160.00 MiB
Device limit : 8.00 GiB
Free (according to CUDA): 0 bytes
PyTorch limit (set by user-supplied memory fraction)
: 17179869184.00 GiB

File "D:\stable_diffusion\ComfyUI\execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "D:\stable_diffusion\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 "D:\stable_diffusion\ComfyUI\execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "D:\stable_diffusion\ComfyUI\custom_nodes\ComfyUI-MagicAnimate\nodes.py", line 253, in generate
sample = pipeline(
File "D:\python\python3.10\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\stable_diffusion\ComfyUI\custom_nodes\ComfyUI-MagicAnimate\libs\magicanimate\pipelines\pipeline_animation.py", line 699, in __call__
down_block_res_samples, mid_block_res_sample = self.controlnet(
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\stable_diffusion\ComfyUI\custom_nodes\ComfyUI-MagicAnimate\libs\magicanimate\models\controlnet.py", line 529, in forward
sample, res_samples = downsample_block(
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\diffusers\models\unet_2d_blocks.py", line 1086, in forward
hidden_states = attn(
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\diffusers\models\transformer_2d.py", line 315, in forward
hidden_states = block(
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\diffusers\models\attention.py", line 248, in forward
ff_output = self.ff(norm_hidden_states, scale=lora_scale)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\diffusers\models\attention.py", line 307, in forward
hidden_states = module(hidden_states, scale)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "D:\python\python3.10\lib\site-packages\diffusers\models\attention.py", line 356, in forward
return hidden_states * self.gelu(gate)

From the code, I encountered the exception while running ControlNet. my notebook has only 8GB of VRAM. How much VRAM is required to run this workflow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions