ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.

Open makisekurisu-jp opened this issue 1 year ago • 11 comments

Custom Node Testing

Expected Behavior

Image

This model combination used to run smoothly on my GPU, but recent ComfyUI updates have introduced persistent OOM errors. I suspect a performance regression in the latest builds.

Actual Behavior

Image

Steps to Reproduce

[START] Security scan
[DONE] Security scan
## ComfyUI-Manager: installing dependencies done.
** ComfyUI startup time: 2025-10-31 14:27:16.615
** Platform: Windows
** Python version: 3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]
** Python executable: D:\ComfyUI\venv\Scripts\Python.exe
** ComfyUI Path: D:\ComfyUI
** ComfyUI Base Folder Path: D:\ComfyUI
** User directory: D:\ComfyUI\user
** ComfyUI-Manager config path: D:\ComfyUI\user\default\ComfyUI-Manager\config.ini
** Log path: D:\ComfyUI\user\comfyui.log

Prestartup times for custom nodes:
   0.0 seconds: D:\ComfyUI\custom_nodes\rgthree-comfy
   0.0 seconds: D:\ComfyUI\custom_nodes\ComfyUI-Easy-Use
   9.4 seconds: D:\ComfyUI\custom_nodes\ComfyUI-Manager

Checkpoint files will always be loaded safely.
Total VRAM 12282 MB, total RAM 16106 MB
pytorch version: 2.8.0+cu128
xformers version: 0.0.32.post2
Enabled fp16 accumulation.
Set vram state to: NORMAL_VRAM
Device: cuda:0 NVIDIA GeForce RTX 4070 Ti : cudaMallocAsync
Using xformers attention
Python version: 3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]
ComfyUI version: 0.3.67
ComfyUI frontend version: 1.28.8
[Prompt Server] web root: D:\ComfyUI\venv\Lib\site-packages\comfyui_frontend_package\static
[ComfyUI-Easy-Use] server: v1.3.4 Loaded
[ComfyUI-Easy-Use] web root: D:\ComfyUI\custom_nodes\ComfyUI-Easy-Use\web_version/v2 Loaded
ComfyUI-GGUF: Allowing full torch compile
[JoyCaption] GGUF nodes loaded successfully.
### Loading: ComfyUI-Manager (V3.37)
[ComfyUI-Manager] network_mode: public
[ComfyUI-Manager] Since --preview-method is set, ComfyUI-Manager's preview method feature will be ignored.
### ComfyUI Version: v0.3.67-21-g27d1bd88 | Released on '2025-10-30'

Debug Logs

got prompt
Requested to load QwenImage
loaded partially; 9178.35 MB usable, 9177.97 MB loaded, 3390.29 MB offloaded, lowvram patches: 0
Attempting to release mmap (513)
!!! Exception during processing !!! CUDA error: out of memory
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.

Traceback (most recent call last):
  File "D:\ComfyUI\execution.py", line 510, 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, hidden_inputs=hidden_inputs)
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\execution.py", line 324, 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, hidden_inputs=hidden_inputs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\execution.py", line 298, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "D:\ComfyUI\execution.py", line 286, in process_inputs
    result = f(**inputs)
             ^^^^^^^^^^^
  File "D:\ComfyUI\nodes.py", line 1525, in sample
    return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\nodes.py", line 1492, in common_ksampler
    samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\sample.py", line 60, 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 "D:\ComfyUI\comfy\samplers.py", line 1163, 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 "D:\ComfyUI\comfy\samplers.py", line 1053, in sample
    return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\samplers.py", line 1035, in sample
    output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed, latent_shapes=latent_shapes)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\patcher_extension.py", line 112, in execute
    return self.original(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\samplers.py", line 984, in outer_sample
    self.inner_model, self.conds, self.loaded_models = comfy.sampler_helpers.prepare_sampling(self.model_patcher, noise.shape, self.conds, self.model_options)
                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\sampler_helpers.py", line 130, in prepare_sampling
    return executor.execute(model, noise_shape, conds, model_options=model_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\patcher_extension.py", line 112, in execute
    return self.original(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\sampler_helpers.py", line 138, in _prepare_sampling
    comfy.model_management.load_models_gpu([model] + models, memory_required=memory_required + inference_memory, minimum_memory_required=minimum_memory_required + inference_memory)
  File "D:\ComfyUI\comfy\model_management.py", line 697, in load_models_gpu
    loaded_model.model_load(lowvram_model_memory, force_patch_weights=force_patch_weights)
  File "D:\ComfyUI\comfy\model_management.py", line 506, in model_load
    self.model_use_more_vram(use_more_vram, force_patch_weights=force_patch_weights)
  File "D:\ComfyUI\comfy\model_management.py", line 535, in model_use_more_vram
    return self.model.partially_load(self.device, extra_memory, force_patch_weights=force_patch_weights)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\comfy\model_patcher.py", line 934, in partially_load
    raise e
  File "D:\ComfyUI\comfy\model_patcher.py", line 931, in partially_load
    self.load(device_to, lowvram_model_memory=current_used + extra_memory, force_patch_weights=force_patch_weights, full_load=full_load)
  File "D:\ComfyUI\custom_nodes\ComfyUI-GGUF\nodes.py", line 103, in load
    m.to(self.load_device).to(self.offload_device)
    ^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\venv\Lib\site-packages\torch\nn\modules\module.py", line 1369, in to
    return self._apply(convert)
           ^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\venv\Lib\site-packages\torch\nn\modules\module.py", line 955, in _apply
    param_applied = fn(param)
                    ^^^^^^^^^
  File "D:\ComfyUI\venv\Lib\site-packages\torch\nn\modules\module.py", line 1355, in convert
    return t.to(
           ^^^^^
  File "D:\ComfyUI\custom_nodes\ComfyUI-GGUF\ops.py", line 58, in to
    new = super().to(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\ComfyUI\venv\Lib\site-packages\torch\_tensor.py", line 1669, in __torch_function__
    ret = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
torch.AcceleratorError: CUDA error: out of memory
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.


Prompt executed in 4.63 seconds

Other

No response

makisekurisu-jp avatar Oct 31 '25 08:10 makisekurisu-jp

yep same problem

DonnyStruiwig avatar Oct 31 '25 23:10 DonnyStruiwig

This is a problem with --fast and the gguf node.

comfyanonymous avatar Nov 01 '25 00:11 comfyanonymous

This is a problem with --fast and the gguf node.

@city96

makisekurisu-jp avatar Nov 01 '25 02:11 makisekurisu-jp

同样的问题

2259819800 avatar Nov 01 '25 06:11 2259819800

There’s no issue when I revert to the official version 0.3.66, so I don’t think this problem is caused by city96’s custom node.

makisekurisu-jp avatar Nov 01 '25 12:11 makisekurisu-jp

Hmm, Is this specific to RTX 40XX and 50XX cards? I was linked the PR with the ops rework beforehand but I wasn't seeing any failures like this on my 3080 even with --fast (which is the only modern card I own)

(could also be a torch version or cuda version thing, as I'm on 2.7.1+cu128)

city96 avatar Nov 02 '25 06:11 city96

Hmm, Is this specific to RTX 40XX and 50XX cards? I was linked the PR with the ops rework beforehand but I wasn't seeing any failures like this on my 3080 even with --fast (which is the only modern card I own)

(could also be a torch version or cuda version thing, as I'm on 2.7.1+cu128)

I'm also using a 3080, but with PyTorch 2.9 and PyTorch 2.10 (nightly). I had some problems with the text encoder, removing the --fast args is the current workaround.

jprsyt5 avatar Nov 02 '25 07:11 jprsyt5

Hmm, Is this specific to RTX 40XX and 50XX cards? I was linked the PR with the ops rework beforehand but I wasn't seeing any failures like this on my 3080 even with --fast (which is the only modern card I own)

(could also be a torch version or cuda version thing, as I'm on 2.7.1+cu128)

I can reproduce on my 3060. I was able to workaround by placing the mmap offload one shot before the super class load. This blows up ram usage however. The right fix afaics is to hook the new memory pinning from the GGUF subclass, and offload mmap right before the tensor pin and then mark those tensors as already mmap offloaded.

I'm about 5 hours away from a PR for this as I'm on the road atm.

rattus128 avatar Nov 02 '25 09:11 rattus128

https://github.com/city96/ComfyUI-GGUF/pull/355/files @city96

Anyone following who tests it LMK if the results good or bad.

rattus128 avatar Nov 02 '25 10:11 rattus128

Absolutely phenomenal - after updating getting this sh*t as well. Beyond tired of this. Tried a few workarounds, its not worth it and dont have the time - just used a backup comfy. Until this is sorted wont be updating at all - everything i need works...for now...

Raxephion avatar Nov 11 '25 07:11 Raxephion

Switching ComfyUI back to version 0.3.66 works for me on this issue.

AfterHAL avatar Nov 16 '25 10:11 AfterHAL