ComfyUI-PhotoMaker-ZHO icon indicating copy to clipboard operation
ComfyUI-PhotoMaker-ZHO copied to clipboard

Allocation on device 0 would exceed allowed memory. (out of memory)

Open SaschInMotion opened this issue 1 year ago • 4 comments

Hi People, if I want to use PhotoMaker i get this error:

Error occurred when executing NEW_PhotoMaker_Generation:

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

File "D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 152, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\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 "D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-PhotoMaker-ZHO\PhotoMakerNode.py", line 396, in generate_image output = pipe( ^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-PhotoMaker-ZHO\pipeline.py", line 475, in call image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\utils\accelerate_utils.py", line 46, in wrapper return method(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\models\autoencoders\autoencoder_kl.py", line 304, in decode decoded = self._decode(z).sample ^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\models\autoencoders\autoencoder_kl.py", line 275, in _decode dec = self.decoder(z) ^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\models\autoencoders\vae.py", line 338, in forward sample = up_block(sample, latent_embeds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\models\unet_2d_blocks.py", line 2535, in forward hidden_states = upsampler(hidden_states) ^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\diffusers\models\upsampling.py", line 186, in forward hidden_states = self.conv(hidden_states) ^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1511, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1520, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\conv.py", line 460, in forward return self._conv_forward(input, self.weight, self.bias) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\torch\nn\modules\conv.py", line 456, in _conv_forward return F.conv2d(input, weight, bias, self.stride, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Close

Do you have any Ideas to fix it?

My graphic card is a nvidia gtx 4070 ti

I've tried to reinstall the drivers, but nothing happend.

Thanks & Cheers

Sascha

SaschInMotion avatar Feb 02 '24 12:02 SaschInMotion

I get the same error. I'm using 3050ti, but it happens only once after running CompyUI on that node unconditionally.

And, even though Generation set it low, it does not proceed to the next one due to a memory error.

Neytiri7 avatar Feb 13 '24 14:02 Neytiri7

I got the same issue while I set cuda_device=2 launching ComfyUI, but got the same error about that with "device 0". But it occurs with batch_size=4. With batch_size=1 and all other settings remains, it works properly. btw, same kind of memory error output sometimes happens when running original photomaker ipynb demo. Wonder they have the same reason.

plusultra-maker avatar Apr 11 '24 18:04 plusultra-maker

Having the same issue. Not sure if anyone of you resolved this?

freshlesh3 avatar May 01 '24 07:05 freshlesh3

same issue with batch in 1 and 4070 12gb VRAM dedicated to comfy in linux

Milor123 avatar May 01 '24 16:05 Milor123