Description
Describe the bug
Hello, 👋
When trying out ComfyUI's tutorial with the Stable Diffusion model, I get the error
UR error
I found GitHub issues related to the problem of allocating more than 4Gb (e.g., #325). So, I also tried setting
UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
but this has not changed anything.
Without setting that environment variable I had out-of-memory issues for the script below. When I set it, the out-of-memory issue is gone. So, I assume the initial problem and the reported UR error
are not related to this.
import torch
torch.manual_seed(0)
x = torch.rand(47000, 47000, dtype=torch.float32, device='xpu')
# the above works on with UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1 being set
Also, monitoring the GPU did not reveal anything special: I can see that the Python process uses it before the error appears, but that's it.
I have searched for similar issues and could not find anything specific except for #325. But, as said above, it does not seem to be related to the memory allocation issue.
Used setup
- Ubuntu 24.04.1 LTS
- Python
3.12
- ComfyUI
v0.0.2-736-g8d88bfaf
- GPU: Intel(R) UHD Graphics, TigerLake-H GT1
# based on https://dgpu-docs.intel.com/driver/client/overview.html#installing-client-gpus-on-ubuntu-desktop-24-04-lts
wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | \
sudo gpg --yes --dearmor --output /usr/share/keyrings/intel-graphics.gpg
echo "deb [arch=amd64,i386 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu noble client" | \
sudo tee /etc/apt/sources.list.d/intel-gpu-noble.list
sudo apt update
apt-get install -y libze-intel-gpu1 libze1 intel-opencl-icd clinfo intel-gsc
apt-get install -y libze-dev intel-ocloc
# missing in the instructions, unsure if needed
apt-get install -y intel-level-zero-gpu
After cloning the ComfyUI repository:
# python
pyenv install 3.12
pyenv local 3.12
# create virtual env
python -m venv comfyui-venv
source comfyui-venv/bin/activate
pip install --upgrade pip
# https://pytorch-extension.intel.com/installation?platform=gpu&version=v2.5.10%20xpu&os=linux/wsl2&package=pip
python -m pip install torch==2.5.1+cxx11.abi torchvision==0.20.1+cxx11.abi torchaudio==2.5.1+cxx11.abi intel-extension-for-pytorch==2.5.10+xpu oneccl_bind_pt==2.5.0+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
# install other requirements
pip install -r requirements.txt
How to reproduce
python main.py # or with UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
# in the UI, execute the workflow
Logs
Checkpoint files will always be loaded safely.
[W204 15:12:02.899304886 OperatorEntry.cpp:155] Warning: Warning only once for all operators, other operators may also be overridden.
Overriding a previously registered kernel for the same operator and the same dispatch key
operator: aten::_cummax_helper(Tensor self, Tensor(a!) values, Tensor(b!) indices, int dim) -> ()
registered at /build/pytorch/build/aten/src/ATen/RegisterSchema.cpp:6
dispatch key: XPU
previous kernel: registered at /build/pytorch/build/aten/src/ATen/RegisterCPU.cpp:30476
new kernel: registered at /build/intel-pytorch-extension/build/Release/csrc/gpu/csrc/aten/generated/ATen/RegisterXPU.cpp:2971 (function operator())
Total VRAM 29456 MB, total RAM 31815 MB
pytorch version: 2.5.1+cxx11.abi
Set vram state to: NORMAL_VRAM
Device: xpu
Using pytorch attention
ComfyUI version: 0.3.13
[Prompt Server] web root: ComfyUI/web
Import times for custom nodes:
0.0 seconds: ComfyUI/custom_nodes/websocket_image_save.py
Starting server
To see the GUI go to: http://127.0.0.1:8188
got prompt
model weight dtype torch.float16, manual cast: None
model_type EPS
Using pytorch attention in VAE
Using pytorch attention in VAE
VAE load device: xpu:0, offload device: cpu, dtype: torch.bfloat16
CLIP/text encoder model load device: xpu:0, offload device: cpu, current: cpu, dtype: torch.float16
loaded diffusion model directly to GPU
Requested to load BaseModel
loaded completely 9.5367431640625e+25 1639.406135559082 True
2025-02-04 15:12:09,982 - _logger.py - IPEX - INFO - Currently split master weight for xpu only support sgd
2025-02-04 15:12:10,002 - _logger.py - IPEX - INFO - Conv BatchNorm folding failed during the optimize process.
2025-02-04 15:12:10,021 - _logger.py - IPEX - INFO - Linear BatchNorm folding failed during the optimize process.
Requested to load SD1ClipModel
loaded completely 26585.26240234375 235.84423828125 True
2025-02-04 15:12:10,206 - _logger.py - IPEX - INFO - Currently split master weight for xpu only support sgd
2025-02-04 15:12:10,211 - _logger.py - IPEX - INFO - Conv BatchNorm folding failed during the optimize process.
2025-02-04 15:12:10,214 - _logger.py - IPEX - INFO - Linear BatchNorm folding failed during the optimize process.
!!! Exception during processing !!! UR error
Traceback (most recent call last):
File "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 "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 "ComfyUI/execution.py", line 174, in _map_node_over_list
process_inputs(input_dict, i)
File "ComfyUI/execution.py", line 163, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/nodes.py", line 69, in encode
return (clip.encode_from_tokens_scheduled(tokens), )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 148, in encode_from_tokens_scheduled
pooled_dict = self.encode_from_tokens(tokens, return_pooled=return_pooled, return_dict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd.py", line 210, in encode_from_tokens
o = self.cond_stage_model.encode_token_weights(tokens)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 635, in encode_token_weights
out = getattr(self, self.clip).encode_token_weights(token_weight_pairs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 45, in encode_token_weights
o = self.encode(to_encode)
^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 252, in encode
return self(tokens)
^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/sd1_clip.py", line 224, in forward
outputs = self.transformer(tokens, attention_mask_model, intermediate_output=self.layer_idx, final_layer_norm_intermediate=self.layer_norm_hidden_state, dtype=torch.float32)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/clip_model.py", line 137, in forward
x = self.text_model(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/clip_model.py", line 101, in forward
x = self.embeddings(input_tokens, dtype=dtype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/clip_model.py", line 82, in forward
return self.token_embedding(input_tokens, out_dtype=dtype) + comfy.ops.cast_to(self.position_embedding.weight, dtype=dtype, device=input_tokens.device)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfyui-venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/ops.py", line 209, in forward
return self.forward_comfy_cast_weights(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ComfyUI/comfy/ops.py", line 205, in forward_comfy_cast_weights
raise error
File "ComfyUI/comfy/ops.py", line 201, in forward_comfy_cast_weights
return torch.nn.functional.embedding(input, weight, self.padding_idx, self.max_norm, self.norm_type, self.scale_grad_by_freq, self.sparse).to(dtype=output_dtype)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: UR error
Prompt executed in 29.72 seconds
Versions
[W204 15:14:18.169990945 OperatorEntry.cpp:155] Warning: Warning only once for all operators, other operators may also be overridden.
Overriding a previously registered kernel for the same operator and the same dispatch key
operator: aten::_cummax_helper(Tensor self, Tensor(a!) values, Tensor(b!) indices, int dim) -> ()
registered at /build/pytorch/build/aten/src/ATen/RegisterSchema.cpp:6
dispatch key: XPU
previous kernel: registered at /build/pytorch/build/aten/src/ATen/RegisterCPU.cpp:30476
new kernel: registered at /build/intel-pytorch-extension/build/Release/csrc/gpu/csrc/aten/generated/ATen/RegisterXPU.cpp:2971 (function operator())
Collecting environment information...
=====================================
PyTorch version: 2.5.1+cxx11.abi
PyTorch CXX11 ABI: Yes
IPEX version: 2.5.10+xpu
IPEX commit: 90fdb70e7
Build type: Release
OS: Ubuntu 24.04.1 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: N/A
IGC version: N/A
CMake version: N/A
Libc version: glibc-2.39
Python version: 3.12.8 (main, Feb 4 2025, 07:44:03) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.8.0-52-generic-x86_64-with-glibc2.39
Is XPU available: True
DPCPP runtime: N/A
MKL version: N/A
GPU models and configuration onboard:
N/A
GPU models and configuration detected:
* [0] _XpuDeviceProperties(name='Intel(R) UHD Graphics', platform_name='Intel(R) oneAPI Unified Runtime over Level-Zero', type='gpu', driver_version='1.3.29735+27', total_memory=29456MB, max_compute_units=32, gpu_eu_count=32, gpu_subslice_count=2, max_work_group_size=512, max_num_sub_groups=64, sub_group_sizes=[8 16 32], has_fp16=1, has_fp64=0, has_atomic64=1)
Driver version:
* intel_opencl: 24.39.31294.20-1032~24.04
* level_zero: 1.3.29735.27-914~24.04
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
Vendor ID: GenuineIntel
Model name: 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
CPU family: 6
Model: 141
Thread(s) per core: 2
Core(s) per socket: 8
Socket(s): 1
Stepping: 1
CPU(s) scaling MHz: 31%
CPU max MHz: 4800.0000
CPU min MHz: 800.0000
BogoMIPS: 4992.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 384 KiB (8 instances)
L1i cache: 256 KiB (8 instances)
L2 cache: 10 MiB (8 instances)
L3 cache: 24 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-15
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip] dpcpp-cpp-rt==2025.0.4
[pip] impi-devel==2021.14.0
[pip] impi-rt==2021.14.0
[pip] intel-cmplr-lib-rt==2025.0.4
[pip] intel-cmplr-lib-ur==2025.0.4
[pip] intel-cmplr-lic-rt==2025.0.4
[pip] intel_extension_for_pytorch==2.5.10+xpu
[pip] intel-opencl-rt==2025.0.4
[pip] intel-openmp==2025.0.4
[pip] intel-pti==0.10.0
[pip] intel-sycl-rt==2025.0.4
[pip] mkl==2025.0.1
[pip] mkl-dpcpp==2025.0.1
[pip] numpy==2.2.2
[pip] oneccl==2021.14.1
[pip] oneccl-bind-pt==2.5.0+xpu
[pip] oneccl-devel==2021.14.1
[pip] onemkl-sycl-blas==2025.0.1
[pip] onemkl-sycl-datafitting==2025.0.1
[pip] onemkl-sycl-dft==2025.0.1
[pip] onemkl-sycl-lapack==2025.0.1
[pip] onemkl-sycl-rng==2025.0.1
[pip] onemkl-sycl-sparse==2025.0.1
[pip] onemkl-sycl-stats==2025.0.1
[pip] onemkl-sycl-vm==2025.0.1
[pip] torch==2.5.1+cxx11.abi
[pip] torchaudio==2.5.1+cxx11.abi
[pip] torchsde==0.2.6
[pip] torchvision==0.20.1+cxx11.abi
[pip] transformers==4.48.2