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
55.39k stars 5.85k forks source link

Error occurred when executing KSampler: Out of memory #2676

Open nothingness6 opened 9 months ago

nothingness6 commented 9 months ago

My laptop has RTX3060 6GB and someone said that it's enough for running the workflow below:

animatediff-v2v-controlnet-openpose-HED-LCM-LoRA-detailer2.json

I downloaded and launched it, but faced an error. Here are the workflow and the error messages:

Error occurred when executing KSampler:

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

File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\nodes.py", line 1355, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\nodes.py", line 1325, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-Impact-Pack\modules\impact\sample_error_enhancer.py", line 22, in informative_sample
raise e
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\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 "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 284, in motion_sample
return wrap_function_to_inject_xformers_bug_info(orig_comfy_sample)(model, noise, *args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\model_utils.py", line 205, in wrapped_function
return function_to_wrap(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\sample.py", line 100, in sample
samples = sampler.sample(noise, positive_copy, negative_copy, cfg=cfg, latent_image=latent_image, start_step=start_step, last_step=last_step, force_full_denoise=force_full_denoise, denoise_mask=noise_mask, sigmas=sigmas, callback=callback, disable_pbar=disable_pbar, seed=seed)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 712, in sample
return sample(self.model, noise, positive, negative, cfg, self.device, sampler, sigmas, self.model_options, latent_image=latent_image, denoise_mask=denoise_mask, callback=callback, disable_pbar=disable_pbar, seed=seed)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 618, in sample
samples = sampler.sample(model_wrap, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 557, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\k_diffusion\sampling.py", line 745, in sample_lcm
denoised = model(x, sigmas[i] * s_in, **extra_args)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 281, in forward
out = self.inner_model(x, sigma, cond=cond, uncond=uncond, cond_scale=cond_scale, model_options=model_options, seed=seed)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 271, in forward
return self.apply_model(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\samplers.py", line 268, in apply_model
out = sampling_function(self.inner_model, x, timestep, uncond, cond, cond_scale, model_options=model_options, seed=seed)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 632, in sliding_sampling_function
cond, uncond = calc_cond_uncond_batch(model, cond, uncond, x, timestep, model_options)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 488, in calc_cond_uncond_batch
c['control'] = control.get_control(input_x, timestep_, c, len(cond_or_uncond))
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet\adv_control\utils.py", line 411, in get_control_inject
return self.get_control_advanced(x_noisy, t, cond, batched_number)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet\adv_control\control.py", line 29, in get_control_advanced
return self.sliding_get_control(x_noisy, t, cond, batched_number)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-Advanced-ControlNet\adv_control\control.py", line 75, in sliding_get_control
control = self.control_model(x=x_noisy.to(dtype), hint=self.cond_hint, timesteps=timestep.float(), context=context.to(dtype), y=y)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\cldm\cldm.py", line 305, in forward
h = module(h, emb, context)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\diffusionmodules\openaimodel.py", line 59, in forward
return forward_timestep_embed(self, *args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\custom_nodes\ComfyUI-AnimateDiff-Evolved\animatediff\sampling.py", line 103, in forward_timestep_embed
x = layer(x, context, transformer_options)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\attention.py", line 613, in forward
x = block(x, context=context[i], transformer_options=transformer_options)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\attention.py", line 440, in forward
return checkpoint(self._forward, (x, context, transformer_options), self.parameters(), self.checkpoint)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\diffusionmodules\util.py", line 189, in checkpoint
return func(*inputs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\attention.py", line 550, in _forward
x = self.ff(self.norm3(x))
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\attention.py", line 82, in forward
return self.net(x)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\container.py", line 215, in forward
input = module(input)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ldm\modules\attention.py", line 61, in forward
x, gate = self.proj(x).chunk(2, dim=-1)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ops.py", line 25, in forward
return self.forward_comfy_cast_weights(*args, **kwargs)
File "P:\AI_Tools\StabilityMatrix-win-x64\Data\Packages\ComfyUI\comfy\ops.py", line 21, in forward_comfy_cast_weights
return torch.nn.functional.linear(input, weight, bias)

Close
Queue size: 0⚙️
Queue Prompt
Extra options
Queue FrontView QueueView History
Save
Load
Refresh
Clipspace
Clear
Load Default
Manager
Share
To avoid controlnet rendering the background of the video, use Runway to create a green screen video and use it as input. You can do it with a free account. https://runwayml.com/

frame_load_cap: Max number of frames. Set to 16 to 60 for fast testing. Set to higher values for final generation.

# imp v1.0
https://civitai.com/models/56680/imp
- clip skip: -1

# dreamshaper 8 lcm
https://civitai.com/models/4384?modelVersionId=252914
- clip skip: -1
- cfg: ~2
- 5-15 steps
ltdrdata commented 9 months ago

If you change the parameter of SAMLoader from AUTO to CPU, it may reduce VRAM usage.

nothingness6 commented 9 months ago

If you change the parameter of SAMLoader from AUTO to CPU, it may reduce VRAM usage.

Hi, thanks for the answer. I gave it a shot, but no luck. The same error messages :( SAMLoader

dwgeneral commented 5 months ago

hi @nothingness6 , any update for this issue? the same issue occurred

BenDes21 commented 2 months ago

Any update ? same error....

ltdrdata commented 1 month ago

Any update ? same error....

In most cases, this situation occurs due to a lack of hardware resources.

We cannot assist unless it's a special case where a previously well-functioning workflow suddenly stops working, or if you're experiencing an OOM error despite having sufficient VRAM compared to the model size. In most other situations, I won't be able to help.

If your situation falls under these special circumstances, please create a separate issue and include specific details about your hardware spec, software environement(os, torch packages, comfyui commit hash, ...), model, workflow and log.