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

torch.OutOfMemoryError: Allocation on device #211

Open
bluesky61 opened this issue Feb 5, 2025 · 6 comments
Open

torch.OutOfMemoryError: Allocation on device #211

bluesky61 opened this issue Feb 5, 2025 · 6 comments

Comments

@bluesky61
Copy link

My PC uses GTX3070.

When I start running the GGUF workflow, I get an OutOfMemoryError at the Negative Prompt, but what's even weirder is that if I press the "Queue" button again, it goes through and generates the image just fine.

This happens at least 5 times out of 10, and I think the owner need to find out why this is happening.

ComfyUI Error Report

Error Details

  • Node ID: 33
  • Node Type: CLIPTextEncode
  • Exception Type: torch.OutOfMemoryError
  • Exception Message: Allocation on device

Stack Trace

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 327, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 202, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 174, in _map_node_over_list
    process_inputs(input_dict, i)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 163, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\nodes.py", line 67, in encode
    return (clip.encode_from_tokens_scheduled(tokens), )
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 146, in encode_from_tokens_scheduled
    pooled_dict = self.encode_from_tokens(tokens, return_pooled=return_pooled, return_dict=True)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 207, in encode_from_tokens
    self.load_model()

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\sd.py", line 240, in load_model
    model_management.load_model_gpu(self.patcher)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 555, in load_model_gpu
    return load_models_gpu([model])
           ^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 550, in load_models_gpu
    loaded_model.model_load(lowvram_model_memory, force_patch_weights=force_patch_weights)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 366, in model_load
    self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_management.py", line 395, in model_use_more_vram
    return self.model.partially_load(self.device, extra_memory, force_patch_weights=force_patch_weights)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 759, in partially_load
    raise e

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 756, in partially_load
    self.load(device_to, lowvram_model_memory=current_used + extra_memory, force_patch_weights=force_patch_weights, full_load=full_load)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-GGUF\nodes.py", line 84, in load
    super().load(*args, force_patch_weights=True, **kwargs)

  File "H:\ComfyUI\ComfyUI_windows_portable\ComfyUI\comfy\model_patcher.py", line 607, in load
    x[2].to(device_to)

  File "H:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1340, in to
    return self._apply(convert)
           ^^^^^^^^^^^^^^^^^^^^

  File "H:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 927, in _apply
    param_applied = fn(param)
@al-swaiti
Copy link

al-swaiti commented Feb 11, 2025

i think now its better to use gguf diffusion model loader with native comfyui clip loader (fp8 or fp16)

@bluesky61
Copy link
Author

bluesky61 commented Feb 12, 2025

i think now its better to use gguf diffusion model loader with native comfyui clip loader (fp8 or fp16)

The following CLIP Loader exists in Comfy Core.

  • Load CLIP
  • DUALCLIPLoader
  • TripleCLIPLoader

However, none of them can select the GGUF (t5-v1_1-xxl-encoder-f16.gguf) model.

I would appreciate it if you could tell me which node you are referring to.

@al-swaiti
Copy link

al-swaiti commented Feb 12, 2025

gguf clip models not supported in new comfyui versions

@bluesky61
Copy link
Author

gguf clip models not supported in new comfyui versions

I don't understand, I just tried to create an image using the DUALCLIPLoader(GGUF) node from ComfyUI-GGUF a while ago and it worked fine.
I am using ComfyUI v0.3.14, the latest version.

@al-swaiti
Copy link

al-swaiti commented Feb 15, 2025

try this trick to pypass negative prompt or using this workflow where NEG not needed (drop image to comfyui)https://comfyanonymous.github.io/ComfyUI_examples/flux/flux_dev_example.png

Image

@bluesky61
Copy link
Author

Thank you very much. With the {ConditioningZeroOut], the excution time is reduced. Although the "OutOfMemoryError" appears at Positive prompt this time. :)

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

2 participants