ROCm 6.2.4 + torch 270 = VRAM OOM
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
### Expected Behavior
I load my slightly customized flux workflow and got picture
[TestFlux.json](https://github.com/user-attachments/files/20023009/TestFlux.json)
### Actual Behavior
At some point the video memory consumption exceeded 19.9+ GB and I had an VRAM OOM.
### Steps to Reproduce
1. Install ComfyUI + torch270 + ROCM6.2.4
2. Start ComfyUI by default `python main.py`
3. load and run workflow + [LORA](https://https://civitai.com/models/667086?modelVersionId=746602) + [Colossus v1.0_FP16](https://civitai.com/models/833086?modelVersionId=940696) + [customized Colossus CLIP_L](https://civitai.com/models/833086?modelVersionId=937504)
4. VRAM OOM
### Debug Logs
```powershell
## ComfyUI-Manager: installing dependencies done.
[2025-05-03 17:17:00.440] ** ComfyUI startup time: 2025-05-03 17:17:00.440
[2025-05-03 17:17:00.440] ** Platform: Linux
[2025-05-03 17:17:00.440] ** Python version: 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)]
[2025-05-03 17:17:00.440] ** Python executable: /opt/270/ComfyUI/venv/bin/python
[2025-05-03 17:17:00.440] ** ComfyUI Path: /opt/270/ComfyUI
[2025-05-03 17:17:00.440] ** ComfyUI Base Folder Path: /opt/270/ComfyUI
[2025-05-03 17:17:00.440] ** User directory: /opt/270/ComfyUI/user
[2025-05-03 17:17:00.441] ** ComfyUI-Manager config path: /opt/270/ComfyUI/user/default/ComfyUI-Manager/config.ini
[2025-05-03 17:17:00.441] ** Log path: /opt/270/ComfyUI/user/comfyui.log
Prestartup times for custom nodes:
[2025-05-03 17:17:00.901] 1.3 seconds: /opt/270/ComfyUI/custom_nodes/comfyui-manager
[2025-05-03 17:17:00.901]
[2025-05-03 17:17:03.167] Checkpoint files will always be loaded safely.
[2025-05-03 17:17:12.139] Total VRAM 20464 MB, total RAM 64190 MB
[2025-05-03 17:17:12.139] pytorch version: 2.7.0+rocm6.2.4
[2025-05-03 17:17:12.139] AMD arch: gfx1100
[2025-05-03 17:17:12.139] Set vram state to: NORMAL_VRAM
[2025-05-03 17:17:12.139] Device: cuda:0 AMD Radeon RX 7900 XT : native
[2025-05-03 17:17:13.568] Using pytorch attention
[2025-05-03 17:17:14.754] Python version: 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 15.0.1 20250418 (Red Hat 15.0.1-0)]
[2025-05-03 17:17:14.754] ComfyUI version: 0.3.30
[2025-05-03 17:17:14.757] ComfyUI frontend version: 1.18.6
[2025-05-03 17:17:14.758] [Prompt Server] web root: /opt/270/ComfyUI/venv/lib/python3.13/site-packages/comfyui_frontend_package/static
[2025-05-03 17:17:15.212] ### Loading: ComfyUI-Manager (V3.31.13)
[2025-05-03 17:17:15.212] [ComfyUI-Manager] network_mode: public
[2025-05-03 17:17:15.253] ### ComfyUI Revision: 3389 [a97f2f85] *DETACHED | Released on '2025-04-24'
[2025-05-03 17:17:15.274] [92m[save_image_extended] AVIF is supported! Woohoo![0m
[2025-05-03 17:17:15.274] [92m[save_image_extended][0m JXL is not supported. To add it: pip install jxlpy[0m
[2025-05-03 17:17:15.274] [92m[save_image_extended][0m You will need a valid MSVC env to build the wheel[0m
[2025-05-03 17:17:15.274] [92m[save_image_extended][0m version: 2.64[0m
[2025-05-03 17:17:15.283]
[32mInitializing ControlAltAI Nodes[0m
[2025-05-03 17:17:15.441]
Import times for custom nodes:
[2025-05-03 17:17:15.441] 0.0 seconds: /opt/270/ComfyUI/custom_nodes/websocket_image_save.py
[2025-05-03 17:17:15.441] 0.0 seconds: /opt/270/ComfyUI/custom_nodes/controlaltai-nodes
[2025-05-03 17:17:15.442] 0.0 seconds: /opt/270/ComfyUI/custom_nodes/save-image-extended-comfyui
[2025-05-03 17:17:15.442] 0.1 seconds: /opt/270/ComfyUI/custom_nodes/comfyui-manager
[2025-05-03 17:17:15.442] 0.2 seconds: /opt/270/ComfyUI/custom_nodes/comfyui-dynamicprompts
[2025-05-03 17:17:15.442]
[2025-05-03 17:17:15.447] Starting server
[2025-05-03 17:17:15.447] To see the GUI go to: http://127.0.0.1:8188
[2025-05-03 17:17:15.591] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json
[2025-05-03 17:17:15.620] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json
[2025-05-03 17:17:15.768] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/github-stats.json
[2025-05-03 17:17:15.842] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json
[2025-05-03 17:17:15.993] [ComfyUI-Manager] default cache updated: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json
[2025-05-03 17:17:20.280] FETCH ComfyRegistry Data: 5/83
[2025-05-03 17:17:24.777] FETCH ComfyRegistry Data: 10/83
[2025-05-03 17:17:29.880] FETCH ComfyRegistry Data: 15/83
[2025-05-03 17:17:34.340] FETCH ComfyRegistry Data: 20/83
[2025-05-03 17:17:39.351] FETCH ComfyRegistry Data: 25/83
[2025-05-03 17:17:43.895] FETCH ComfyRegistry Data: 30/83
[2025-05-03 17:17:48.383] FETCH ComfyRegistry Data: 35/83
[2025-05-03 17:17:52.917] FETCH ComfyRegistry Data: 40/83
[2025-05-03 17:17:57.387] FETCH ComfyRegistry Data: 45/83
[2025-05-03 17:18:01.804] FETCH ComfyRegistry Data: 50/83
[2025-05-03 17:18:06.337] FETCH ComfyRegistry Data: 55/83
[2025-05-03 17:18:10.909] FETCH ComfyRegistry Data: 60/83
[2025-05-03 17:18:15.392] FETCH ComfyRegistry Data: 65/83
[2025-05-03 17:18:19.944] FETCH ComfyRegistry Data: 70/83
[2025-05-03 17:18:24.405] FETCH ComfyRegistry Data: 75/83
[2025-05-03 17:18:29.307] FETCH ComfyRegistry Data: 80/83
[2025-05-03 17:18:32.388] FETCH ComfyRegistry Data [DONE]
[2025-05-03 17:18:32.459] [ComfyUI-Manager] default cache updated: https://api.comfy.org/nodes
[2025-05-03 17:18:32.467] FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json [DONE]
[2025-05-03 17:18:33.124] [ComfyUI-Manager] All startup tasks have been completed.
[2025-05-03 17:18:40.688] got prompt
[2025-05-03 17:18:41.424] Using split attention in VAE
[2025-05-03 17:18:41.425] Using split attention in VAE
[2025-05-03 17:18:41.533] VAE load device: cuda:0, offload device: cpu, dtype: torch.float32
[2025-05-03 17:18:44.370] CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cpu, dtype: torch.float16
[2025-05-03 17:19:02.090] model weight dtype torch.bfloat16, manual cast: None
[2025-05-03 17:19:02.091] model_type FLUX
[2025-05-03 17:19:37.699] New prompt: cute anime girl with massive fluffy fennec ears and a big fluffy tail blonde messy long hair blue eyes wearing a maid outfit with a long black gold leaf pattern dress and a white apron mouth open placing a fancy black forest cake with candles on top of a dinner table of an old dark Victorian mansion lit by candlelight with a bright window to the foggy forest and very expensive stuff everywhere there are paintings on the walls
[2025-05-03 17:19:37.704] Token indices sequence length is longer than the specified maximum sequence length for this model (82 > 77). Running this sequence through the model will result in indexing errors
[2025-05-03 17:19:37.708] Requested to load FluxClipModel_
[2025-05-03 17:19:40.551] loaded completely 19194.8 9319.23095703125 True
[2025-05-03 17:19:41.410] Requested to load Flux
[2025-05-03 17:19:54.879] loaded partially 18782.246 18781.982421875 96
[2025-05-03 17:19:55.499]
[2025-05-03 17:19:55.508] !!! Exception during processing !!! HIP out of memory. Tried to allocate 52.00 MiB. GPU 0 has a total capacity of 19.98 GiB of which 22.00 MiB is free. Of the allocated memory 18.80 GiB is allocated by PyTorch, and 818.92 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_HIP_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
[2025-05-03 17:19:55.515] Traceback (most recent call last):
File "/opt/270/ComfyUI/execution.py", line 347, 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 "/opt/270/ComfyUI/execution.py", line 222, 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 "/opt/270/ComfyUI/execution.py", line 194, in _map_node_over_list
process_inputs(input_dict, i)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/execution.py", line 183, in process_inputs
results.append(getattr(obj, func)(**inputs))
~~~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/opt/270/ComfyUI/comfy_extras/nodes_custom_sampler.py", line 657, in sample
samples = guider.sample(noise.generate_noise(latent), latent_image, sampler, sigmas, denoise_mask=noise_mask, callback=callback, disable_pbar=disable_pbar, seed=noise.seed)
File "/opt/270/ComfyUI/comfy/samplers.py", line 1008, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/opt/270/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/samplers.py", line 976, in outer_sample
output = self.inner_sample(noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/opt/270/ComfyUI/comfy/samplers.py", line 959, in inner_sample
samples = executor.execute(self, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
File "/opt/270/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/samplers.py", line 738, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
File "/opt/270/ComfyUI/venv/lib64/python3.13/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/opt/270/ComfyUI/comfy/k_diffusion/sampling.py", line 161, in sample_euler
denoised = model(x, sigma_hat * s_in, **extra_args)
File "/opt/270/ComfyUI/comfy/samplers.py", line 390, in __call__
out = self.inner_model(x, sigma, model_options=model_options, seed=seed)
File "/opt/270/ComfyUI/comfy/samplers.py", line 939, in __call__
return self.predict_noise(*args, **kwargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/samplers.py", line 942, 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 "/opt/270/ComfyUI/comfy/samplers.py", line 370, in sampling_function
out = calc_cond_batch(model, conds, x, timestep, model_options)
File "/opt/270/ComfyUI/comfy/samplers.py", line 206, in calc_cond_batch
return executor.execute(model, conds, x_in, timestep, model_options)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/samplers.py", line 319, in _calc_cond_batch
output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/model_base.py", line 138, in apply_model
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...<2 lines>...
comfy.patcher_extension.get_all_wrappers(comfy.patcher_extension.WrappersMP.APPLY_MODEL, transformer_options)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
).execute(x, t, c_concat, c_crossattn, control, transformer_options, **kwargs)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/patcher_extension.py", line 111, in execute
return self.original(*args, **kwargs)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/comfy/model_base.py", line 171, in _apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/venv/lib64/python3.13/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/venv/lib64/python3.13/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/270/ComfyUI/comfy/ldm/flux/model.py", line 206, 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 "/opt/270/ComfyUI/comfy/ldm/flux/model.py", line 145, in forward_orig
img, txt = block(img=img,
~~~~~^^^^^^^^^
txt=txt,
^^^^^^^^
vec=vec,
^^^^^^^^
pe=pe,
^^^^^^
attn_mask=attn_mask)
^^^^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/venv/lib64/python3.13/site-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/270/ComfyUI/venv/lib64/python3.13/site-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
File "/opt/270/ComfyUI/comfy/ldm/flux/layers.py", line 190, in forward
attn = attention(torch.cat((txt_q, img_q), dim=2),
torch.cat((txt_k, img_k), dim=2),
torch.cat((txt_v, img_v), dim=2),
pe=pe, mask=attn_mask)
File "/opt/270/ComfyUI/comfy/ldm/flux/math.py", line 16, in attention
q = (pe[..., 0] * q[..., 0] + pe[..., 1] * q[..., 1]).reshape(*q_shape).type_as(v)
~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
torch.OutOfMemoryError: HIP out of memory. Tried to allocate 52.00 MiB. GPU 0 has a total capacity of 19.98 GiB of which 22.00 MiB is free. Of the allocated memory 18.80 GiB is allocated by PyTorch, and 818.92 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_HIP_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
[2025-05-03 17:19:55.518] Got an OOM, unloading all loaded models.
[2025-05-03 17:19:55.585] Prompt executed in 74.88 seconds
[2025-05-03 17:20:23.008]
Stopped server
```
### Other
Radeon RX7900 XT (20GB VRAM)/Python 3.13.3 /Fedora42 KDE
What's interesting:
1. ROCm 6.2.4. + Torch 270 + workflow = VRAM OOM
_(According to the KDE sensor, VRAM consumption reaches 20 GB, then OOM)_
2. ROCm 6.2.4. + Torch 270 + workflow with bypassed LORA = OK
_(According to the KDE sensor, VRAM consumption reaches 19.9 GB)_
3. ROCm 6.2.4 + Torch **260** + workflow = OK
_(According to the KDE sensor, VRAM consumption never exceed 19.8 GB)_
I recall there were some VRAM optimizations for the ROCM + Torch 270 combo
Can I temporarily disable them and how?
Contributor guide
Assessment
This issue has not been assessed yet.