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

OutOfMemoryError: Allocation on device 0 would exceed allowed memory. #19

Open
brechtdecock opened this issue Dec 20, 2023 · 11 comments
Open

Comments

@brechtdecock
Copy link

using the text To Mask node, i get the following error when trying to combine prompts with the pipe | symbol

Works: hat, shoes, jacket

Does not work: hat | shoes | jacket

line 63, in forward_multihead_attention
attn_output_weights = torch.softmax(attn_output_weights, dim=-1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch.cuda.OutOfMemoryError: Allocation on device 0 would exceed allowed memory. (out of memory)
Currently allocated : 15.58 GiB
Requested : 4.45 GiB
Device limit : 12.00 GiB
Free (according to CUDA): 0 bytes
PyTorch limit (set by user-supplied memory fraction)
: 17179869184.00 GiB

@baselqt
Copy link

baselqt commented Dec 23, 2023

same here

@segalinc
Copy link

segalinc commented Feb 2, 2024

After updating ComfyUI memory blows up showing it requires 189GB?

@marcsyp
Copy link

marcsyp commented Mar 3, 2024

+1, tried to allocate 87GB, Mask By Text not working for me either.

@SphaeroX
Copy link

SphaeroX commented Mar 3, 2024

ERROR:root:Traceback (most recent call last):
  File "C:\ComfyUI\execution.py", line 152, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\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 "C:\ComfyUI\execution.py", line 75, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ComfyUI\custom_nodes\masquerade-nodes-comfyui\MaskNodes.py", line 157, in get_mask
    preds = model(img.repeat(len(prompts), 1, 1, 1), dup_prompts)[0]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl
    return forward_call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\clipseg\clipseg.py", line 362, in forward
    visual_q, activations, _ = self.visual_forward(x_inp, extract_layers=[0] + list(self.extract_layers))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\clipseg\clipseg.py", line 172, in visual_forward
    x, aff_per_head = forward_multihead_attention(x, res_block, with_aff=True, attn_mask=attn_mask)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python311\Lib\site-packages\clipseg\clipseg.py", line 63, in forward_multihead_attention
    attn_output_weights = torch.softmax(attn_output_weights, dim=-1)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
torch.cuda.OutOfMemoryError: Allocation on device 0 would exceed allowed memory. (out of memory)
Currently allocated     : 8.52 GiB
Requested               : 3.80 GiB
Device limit            : 11.99 GiB
Free (according to CUDA): 0 bytes
PyTorch limit (set by user-supplied memory fraction)
                        : 17179869184.00 GiB

Prompt executed in 20.19 seconds

@time-river
Copy link

+1. I think the reason is free memory is not timely

@VLevithan
Copy link

+1
image

@zd1990
Copy link

zd1990 commented Apr 11, 2024

can add a "Rebatch Images" node to resovle this issue

@kurt83340
Copy link

+1 same issue TT

@gabrielhrr
Copy link

can add a "Rebatch Images" node to resovle this issue

doesn't work

@jasoncow007
Copy link

+1 same issue TT

@jasoncow007
Copy link

Traceback (most recent call last):
File "D:\ComfyUI-aki-v1.2\execution.py", line 323, 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 "D:\ComfyUI-aki-v1.2\execution.py", line 198, 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 "D:\ComfyUI-aki-v1.2\execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "D:\ComfyUI-aki-v1.2\execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "D:\ComfyUI-aki-v1.2\custom_nodes\masquerade-nodes-comfyui\MaskNodes.py", line 157, in get_mask
preds = model(img.repeat(len(prompts), 1, 1, 1), dup_prompts)[0]
File "D:\ComfyUI-aki-v1.2\python\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "D:\ComfyUI-aki-v1.2\python\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl
return forward_call(*args, **kwargs)
File "D:\ComfyUI-aki-v1.2\python\lib\site-packages\clipseg\clipseg.py", line 362, in forward
visual_q, activations, _ = self.visual_forward(x_inp, extract_layers=[0] + list(self.extract_layers))
File "D:\ComfyUI-aki-v1.2\python\lib\site-packages\clipseg\clipseg.py", line 172, in visual_forward
x, aff_per_head = forward_multihead_attention(x, res_block, with_aff=True, attn_mask=attn_mask)
File "D:\ComfyUI-aki-v1.2\python\lib\site-packages\clipseg\clipseg.py", line 63, in forward_multihead_attention
attn_output_weights = torch.softmax(attn_output_weights, dim=-1)
torch.OutOfMemoryError: Allocation on device

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