Comfy-Org / Comfy-Org/ComfyUI

XPU out of memory on Intel CPU although plenty of memory is available

Open
#9,128 19 comments 0 reactions 0 assignees View on GitHub
bug-cop:non-blocking bug-cop:response-received Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

The FLUX Kontext (Basic) workflow runs on my system with Intel Core Ultra 9 185H and 64GB of RAM.

### Actual Behavior

When trying to run the workflow (following the description provided [here](https://docs.comfy.org/tutorials/flux/flux-1-kontext-dev)), it crashes during the KSampler step with `torch.OutOfMemoryError`. Before starting the workflow, about 50GB of memory are available, so there should be plenty of space for the models.

### Steps to Reproduce

1. Have an Ubuntu 24.04 system with Intel Meteor Lake CPU.
2. Install Intel GPU drivers.
3. Install PyTorch Nightly with XPU support.
4. Install the latest ComfyUI version from GitHub (97b8a2c26a335fe70ac6cfb44bf225454f51d700 at the time of writing, but I've been getting this error for a few weeks).
5. Download models and place them in the correct directories.
6. Run ComfyUI.
7. Load the "FLUX Kontext (Basic)" workflow, input an image and run it.
8. Run out of GPU/XPU memory.

### Debug Logs

```powershell
# ComfyUI Error Report
## Error Details
- **Node ID:** 31
- **Node Type:** KSampler
- **Exception Type:** torch.OutOfMemoryError
- **Exception Message:** XPU out of memory. Tried to allocate 9.57 GiB. GPU 0 has a total capacity of 58.06 GiB. Of the allocated memory 16.93 GiB is allocated by PyTorch, and 237.01 MiB is reserved by PyTorch but unallocated. Please use `empty_cache` to release all unoccupied cached memory.
This error means you ran out of memory on your GPU.

TIPS: If the workflow worked before you might have accidentally set the batch_size to a large number.
## Stack Trace

File "/home/goto-loop/Experiments/ComfyUI/execution.py", line 427, in execute
output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/execution.py", line 270, in get_output_data
return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/execution.py", line 244, in _async_map_node_over_list
await process_inputs(input_dict, i)

File "/home/goto-loop/Experiments/ComfyUI/execution.py", line 232, in process_inputs
result = f(**inputs)
^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/nodes.py", line 1519, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/nodes.py", line 1486, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/sample.py", line 45, in sample
samples = sampler.sample(noise, positive, negative, 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 "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 1143, 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 "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 1033, in sample
return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 1018, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 986, in outer_sample
output = self.inner_sample(noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 969, in inner_sample
samples = executor.execute(self, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 748, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/k_diffusion/sampling.py", line 190, in sample_euler
denoised = model(x, sigma_hat * s_in, **extra_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 400, in __call__
out = self.inner_model(x, sigma, model_options=model_options, seed=seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 949, in __call__
return self.predict_noise(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 952, in predict_noise
return sampling_function(self.inner_model, x, timestep, self.conds.get("negative", None), self.conds.get("positive", None), self.cfg, model_options=model_options, seed=seed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 380, in sampling_function
out = calc_cond_batch(model, conds, x, timestep, model_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 206, in calc_cond_batch
return executor.execute(model, conds, x_in, timestep, model_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/samplers.py", line 325, in _calc_cond_batch
output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/model_base.py", line 152, in apply_model
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/model_base.py", line 190, in _apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/ldm/flux/model.py", line 242, in forward
out = self.forward_orig(img, img_ids, context, txt_ids, timestep, y, guidance, control, transformer_options, attn_mask=kwargs.get("attention_mask", None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/ldm/flux/model.py", line 149, in forward_orig
img, txt = block(img=img,
^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1773, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1784, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/ldm/flux/layers.py", line 190, in forward
attn = attention(torch.cat((txt_q, img_q), dim=2),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/ldm/flux/math.py", line 20, in attention
x = optimized_attention(q, k, v, heads, skip_reshape=True, mask=mask)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/home/goto-loop/Experiments/ComfyUI/comfy/ldm/modules/attention.py", line 451, in attention_pytorch
out = torch.nn.functional.scaled_dot_product_attention(q, k, v, attn_mask=mask, dropout_p=0.0, is_causal=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

## System Information
- **ComfyUI Version:** 0.3.47
- **Arguments:** main.py --disable-all-custom-nodes
- **OS:** posix
- **Python Version:** 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0]
- **Embedded Python:** false
- **PyTorch Version:** 2.9.0.dev20250730+xpu
## Devices

- **Name:** xpu:0 Intel(R) Arc(TM) Graphics
- **Type:** xpu
- **VRAM Total:** 62337916928
- **VRAM Free:** 62337916928
- **Torch VRAM Total:** 0
- **Torch VRAM Free:** 0

## Logs

2025-07-31T15:10:14.339339 - Checkpoint files will always be loaded safely.
2025-07-31T15:10:14.385195 - Total VRAM 59450 MB, total RAM 63723 MB
2025-07-31T15:10:14.385236 - pytorch version: 2.9.0.dev20250730+xpu
2025-07-31T15:10:14.385342 - Set vram state to: NORMAL_VRAM
2025-07-31T15:10:14.385384 - Device: xpu:0 Intel(R) Arc(TM) Graphics
2025-07-31T15:10:15.125284 - Using pytorch attention
2025-07-31T15:10:16.197771 - Python version: 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0]
2025-07-31T15:10:16.197812 - ComfyUI version: 0.3.47
2025-07-31T15:10:16.199625 - ComfyUI frontend version: 1.23.4
2025-07-31T15:10:16.200079 - [Prompt Server] web root: /home/goto-loop/Experiments/comfy/lib/python3.12/site-packages/comfyui_frontend_package/static
2025-07-31T15:10:16.701762 - Skipping loading of custom nodes
2025-07-31T15:10:16.876747 - Context impl SQLiteImpl.
2025-07-31T15:10:16.876789 - Will assume non-transactional DDL.
2025-07-31T15:10:16.877313 - No target revision found.
2025-07-31T15:10:16.880969 - Starting server

2025-07-31T15:10:16.881117 - To see the GUI go to: http://127.0.0.1:8188
2025-07-31T15:10:53.251749 - got prompt
2025-07-31T15:10:53.269872 - Using pytorch attention in VAE
2025-07-31T15:10:53.270595 - Using pytorch attention in VAE
2025-07-31T15:10:53.493279 - VAE load device: xpu:0, offload device: cpu, dtype: torch.float32
2025-07-31T15:10:53.648789 - Requested to load AutoencodingEngine
2025-07-31T15:10:53.792907 - loaded completely 51982.0703125 319.7467155456543 True
2025-07-31T15:10:57.721211 - Using scaled fp8: fp8 matrix mult: False, scale input: False
2025-07-31T15:10:58.043264 - Requested to load FluxClipModel_
2025-07-31T15:10:58.050778 - loaded completely 9.5367431640625e+25 4903.231597900391 True
2025-07-31T15:10:58.054167 - CLIP/text encoder model load device: xpu:0, offload device: cpu, current: xpu:0, dtype: torch.float16
2025-07-31T15:10:58.191898 - clip missing: ['text_projection.weight']
2025-07-31T15:11:02.573341 - Using scaled fp8: fp8 matrix mult: False, scale input: True
2025-07-31T15:11:02.587207 - model weight dtype torch.float16, manual cast: None
2025-07-31T15:11:02.587488 - model_type FLUX
2025-07-31T15:11:03.592517 - Requested to load Flux
2025-07-31T15:11:06.676375 - loaded completely 51973.87530078125 11350.088394165039 True
2025-07-31T15:11:06.782543 -
0%| | 0/20 [00:00

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.