Skip to content

UR error during ComfyUI's tutorial with Stable Diffusion model on Ubuntu with TigerLake-H GT1 #781

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

Open
ValentinaGalataTNG opened this issue Feb 4, 2025 · 9 comments

Comments

@ValentinaGalataTNG
Copy link

ValentinaGalataTNG commented Feb 4, 2025

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
@RogerWeihrauch
Copy link

@ValentinaGalataTNG:
Hi. I am no expert on this, but I read that INTEL's PyTorch extensions (actually, as I am aware of) only work with/need python in Version 3.11.x.
Did u try an elder version of Python,too?
Regards,
Roger

@RogerWeihrauch
Copy link

.. and: Are u really using the iGPU of the processor?
I am not sure if this will work in general, since ComfyUI at least may need >8GB of VRam.
Regards,
Roger

@ValentinaGalataTNG
Copy link
Author

Hi @RogerWeihrauch,

Thanks for your reply!

Hi. I am no expert on this, but I read that INTEL's PyTorch extensions (actually, as I am aware of) only work with/need python in Version 3.11.x.
Did u try an elder version of Python,too?

No, I have not. According to the Intel Extension for PyTorch website, the supported Python versions are 3.9, 3.10, 3.11, 3.12. I went with the latest, i.e., 3.12, since this is also the recommended version for ComfyUI (see here):

python 3.13 is supported but using 3.12 is recommended because some custom nodes and their dependencies might not support it yet.

Regarding your second comment:

.. and: Are u really using the iGPU of the processor?
I am not sure if this will work in general, since ComfyUI at least may need >8GB of VRam.

That's a good point.... When running the small Python script below with setting export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1, I can see in htop that some of the RAM is being allocated as "shared".

import torch
torch.manual_seed(0)
x = torch.rand(47000, 47000, dtype=torch.float32, device='xpu')

If I use torch to check for available XPU devices, I get the following:

torch.xpu.device_count()
# 1

torch.xpu.get_device_properties()
# _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)

torch.xpu.get_device_capability()
# {'driver_version': '1.3.29735+27', 'gpu_eu_count': 32, 'gpu_subslice_count': 2, 'has_atomic64': True, 'has_bfloat16_conversions': False, 'has_fp16': True, 'has_fp64': False, 'has_subgroup_2d_block_io': False, 'has_subgroup_matrix_multiply_accumulate': False, 'has_subgroup_matrix_multiply_accumulate_tensor_float32': False, 'max_compute_units': 32, 'max_num_sub_groups': 64, 'max_work_group_size': 512, 'name': 'Intel(R) UHD Graphics', 'platform_name': 'Intel(R) oneAPI Unified Runtime over Level-Zero', 'sub_group_sizes': [8, 16, 32], 'total_memory': 30887301120, 'type': 'gpu', 'vendor': 'Intel(R) Corporation', 'version': '12.0.0'}

So, it does seem to see the GPU and the available memory is 30 Gb which is the size of my RAM.

I am suspecting that my GPU is a GPU without its own memory which would explain the memory allocation. I have not been able to find the official Intel documentation on this, but have read some people saying that on StackOverflow.

I have not much experience working with GPUs: would that explain the problems with ComfyUI? Obviously, the GPU is there and can be used, as the small Python script above using torch.xpu does work...

@RogerWeihrauch
Copy link

Hi @ValentinaGalataTNG
Ok, so , one more Q:

  1. Are u sure that the python version of Comfyui u'r running is the same as used for the Pytorch extensions for u'r kind of INTEL GPU?
    1a) Are u running it with u'r sytems python version/ w/o any venv?
  2. As far as I know only version 3.11 may run with ComfyUI at amximum; hope I am right.
    in this case u may have to 'downgrade' kind of u'r python version.
    I realize this step by using/installing 'pyenv'. with this I am able to choose between different python version for creating my venv for ComfyUI. So I can use any python/pip version in my venv without touching my system's python version.
    And one more tip:
    do install the INTEL's PyTorch extensions versions after creating u'r venv AND before first start of ComfyUI; since than here will be no other Pytorch extensions versions be downloaded.
    These are the experiences I made on this.
    Regards,
    Roger

@RogerWeihrauch
Copy link

Maybe also an update may help by: git pull.
U should see something like (if there are updates):

(venv) debian@bigdeb:/ComfyUI2$ git pull
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (16/16), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 24 (delta 9), reused 10 (delta 8), pack-reused 8 (from 2)
Unpacking objects: 100% (24/24), 51.30 KiB | 83.00 KiB/s, done.
From https://github.com/comfyanonymous/ComfyUI
af93c8d1..4027466c master -> origin/master
Updating af93c8d1..4027466c
Fast-forward
comfy/k_diffusion/sampling.py | 61 ++++++++++++++++++++++++++++++++++---------------------------
comfy/ldm/lumina/model.py | 5 ++++-
comfy/model_base.py | 3 ---
comfy/model_management.py | 6 ++++++
comfy/samplers.py | 3 ++-
comfy/utils.py | 2 +-
6 files changed, 47 insertions(+), 33 deletions(-)
(venv) debian@bigdeb:
/ComfyUI2$

Regards

@ValentinaGalataTNG
Copy link
Author

ValentinaGalataTNG commented Feb 11, 2025

Hi @RogerWeihrauch,

Thanks again for your suggestions.

✔ I did a git pull today to use the latest version of ConfyUI.

Are u sure that the python version of Comfyui u'r running is the same as used for the Pytorch extensions for u'r kind of INTEL GPU?
1a) Are u running it with u'r sytems python version/ w/o any venv?

Yes, I am quite sure. I use a single Python venv to install ComfyUI dependencies and intel-extension. See also my notes below.

As far as I know only version 3.11 may run with ComfyUI at amximum; hope I am right.
in this case u may have to 'downgrade' kind of u'r python version. [...]
And one more tip:
do install the INTEL's PyTorch extensions versions after creating u'r venv AND before first start of ComfyUI; since than here will be no other Pytorch extensions versions be downloaded.

I removed the previously created venv and created a new one with the following modifications:

  • use Python v3.11
  • check Python version and binary location
  • install the Intel extension and its dependencies as the last step
# python version
pyenv install 3.11
pyenv local 3.11

# create virtual env
python -m venv comfyui-venv
source comfyui-venv/bin/activate

# python version check
python --version # Python 3.11.11
which python # ${PWD}/comfyui-venv/bin/python

# update pip
pip install --upgrade pip

# install ComfyUI requirements
pip install -r requirements.txt

# 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/

# check package versions installed in last step
pip list
# truncated output
# Package                     Version
# --------------------------- ----------------
# intel_extension_for_pytorch 2.5.10+xpu
# oneccl-bind-pt              2.5.0+xpu
# torch                       2.5.1+cxx11.abi
# torchaudio                  2.5.1+cxx11.abi
# torchvision                 0.20.1+cxx11.abi

With this venv still being activated, I ran

python main.py

but still got the same error. 🫤

@RogerWeihrauch
Copy link

@ValentinaGalataTNG:
hmm, u'r venv looks nearly exact the same as on my side. Ok, now I am at the end of my ideas.
maybe a description of my env/system may lead you to another idea: (I am running ComfyUI on both of my Desktops)

  1. Desk1: AMD Threadripper 1900 (elder CPU), 128GB RAM, INTEL ARC A770 GPU from Acer, anything else may be irrelevant
    Desk2: AMD Ryzen 3800X CPU, 64GB RAM, INTEL ARC A770 GPU from Sparkle
  2. I see no difference when exporting UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1, or not before starting them.
  3. the way I set this up is:
    (that is my way to set it up: so NO WARRANTY; this is my kind of manual setup)

Definite Guide to setup CoomfyUI for INTEL ARC A770 GPU:
Pre-reqs:
a) sudo apt install pkg-config console-setup (sentencepiece) python3-sentencepiece
b) HINT:
!If using 'ComfyUI-Yoloworld-EfficientSAM': USE Python version 3.11.xx via 'pyenv'!
-> be sure to reboot before stepping further!

  1. git clone https://github.com/comfyanonymous/ComfyUI.git ./ComfyUI
  2. cd ComfyUI
  3. ~/.pyenv/versions/3.12.5/bin/python -m venv venv venv
    -> system's python version (3.13.x) may not work for some needed pip wheels
  4. . ./venv/bin/activate
  5. python -m ensurepip --upgrade
    5a) pip install --upgrade pip
    5b) pip install --upgrade setuptools
  6. 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/
    -> watch for the latest here before installing! (may also be incompatible with following version of INTEL wheels, but may be resolved by next step)
    ( 6a) pip install --pre torch torchvision torchaudio pytorch-triton-xpu sentencepiece torchmetrics (torchdata==0.12.0.dev20250208) torchcodec (torcharrow) torchao --index-url https://download.pytorch.org/whl/nightly/xpu)
    (6b) pip install --upgrade inference ; pip install transformers -U)
  7. pip install -r requirements.txt
  8. cd ./custom_nodes
  9. git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
  10. cd ..
    10a) export UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1
  11. python main.py --highvram &
  12. update all & enjoy
  13. rm -rf ./venv ./lib ./lib64 ./bin ./include pyvenv.cfg ; to completely remove the virtual python env and all pip installed wheels!

Links:
ComfyUI Manager: https://github.com/ltdrdata/ComfyUI-Manager
pytorch4intel: https://pytorch-extension.intel.com/installation?platform=gpu&version=v2.5.10%2Bxpu&os=linux%2Fwsl2&package=pip
ComfyUI wiki: https://comfyui-wiki.com/en/install

special paths for YOLO which may not be avaiable:

[Impact Subpack] ultralytics_bbox: /home/debian/GenArt/ComfyUI/models/ultralytics/bbox
[Impact Subpack] ultralytics_segm: /home/debian/GenArt/ComfyUI/models/ultralytics/segm

Special nodes to be installed for that:
ComfyUI YoloWorld-EfficientSAM

pip install --upgrade inference
pip install --upgrade supervision
pip install transformers -U
---supervision
Models from ComfyUI-Manager - Model Manager:
MobileSAM

Hope this may help/show you a difference in your way to set it up.
AGAIN: I am not sure if this is the best/most efficient/modern way to set it up, but it works for me.
BTW:
Since the GPU u use seems to share the Desktops/PC memory if i remember right:
Did u enable the BAR option in the Bios?
(I am not sure if this will be necessary w/ u'r HW, but on my side it was very relevant)
Regards,
Roger

@RogerWeihrauch
Copy link

@ValentinaGalataTNG:
Hi. Now got nearly the same error as you received when opening this thread:

File "/home/debian/ComfyUI/venv/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/ComfyUI/comfy/ldm/modules/attention.py", line 577, in forward
out = optimized_attention(q, k, v, self.heads, attn_precision=self.attn_precision)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/debian/ComfyUI/comfy/ldm/modules/attention.py", line 455, in attention_pytorch
out = torch.nn.functional.scaled_dot_product_attention(q, k, v, attn_mask=mask, dropout_p=0.0, is_causal=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: UR error

Prompt executed in 1.90 seconds

BUT: I got this error when the image I wanted to generate was too high in its resolution: image size when this error occurred:
width: 784, height: 920. Before this I got the already known error u already also may have recognized/read about: 'not able to assign more than 4GB on GPU':
#325 (comment)
I already attached with my error onto that issue; u also reported u'r error there.
So, seems to be an error on INTEL's torch extensions.
Dont know how to go on here; did not suffice in described solution there suggested to me, I was not successful on that.
Regards,
Roger

@ValentinaGalataTNG
Copy link
Author

@RogerWeihrauch, thank you!

If I remember correctly, I also tried to set lower values for the image dimensions without much success.
I will take again a look at the linked issue.

@louie-tsai louie-tsai removed their assignment Feb 26, 2025
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

3 participants