Flux.1 Schnell, memory issue on AMD Rocm
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 153
Description
### Expected Behavior
I expect it should work because I can run SDXL with AMD Ryzen 7 7700 on Linux
### Actual Behavior

### Steps to Reproduce
i installed comfyui via docker
```
environment:
CLI_ARGS: "--lowvram --use-split-cross-attention"
HSA_OVERRIDE_GFX_VERSION: "10.3.0"
HIP_VISIBLE_DEVICES: 0
ROCR_VISIBLE_DEVICES: 0
PYTORCH_HIP_ALLOC_CONF: "garbage_collection_threshold:0.6,max_split_size_mb:6144"
```
### Debug Logs
```powershell
Error occurred when executing SamplerCustomAdvanced:
HIP out of memory. Tried to allocate 90.00 MiB. GPU 0 has a total capacty of 512.00 MiB of which 16.00 MiB is free. Of the allocated memory 204.22 MiB is allocated by PyTorch, and 177.78 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_HIP_ALLOC_CONF
File "/root/ComfyUI/execution.py", line 152, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "/root/ComfyUI/execution.py", line 82, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "/root/ComfyUI/execution.py", line 75, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "/root/ComfyUI/comfy_extras/nodes_custom_sampler.py", line 612, 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 "/root/ComfyUI/comfy/samplers.py", line 716, in sample
output = self.inner_sample(noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/root/ComfyUI/comfy/samplers.py", line 695, in inner_sample
samples = sampler.sample(self, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
File "/root/ComfyUI/comfy/samplers.py", line 600, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
File "/usr/local/lib64/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/root/ComfyUI/comfy/k_diffusion/sampling.py", line 143, in sample_euler
denoised = model(x, sigma_hat * s_in, **extra_args)
File "/root/ComfyUI/comfy/samplers.py", line 299, in __call__
out = self.inner_model(x, sigma, model_options=model_options, seed=seed)
File "/root/ComfyUI/comfy/samplers.py", line 682, in __call__
return self.predict_noise(*args, **kwargs)
File "/root/ComfyUI/comfy/samplers.py", line 685, 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 "/root/ComfyUI/comfy/samplers.py", line 279, in sampling_function
out = calc_cond_batch(model, conds, x, timestep, model_options)
File "/root/ComfyUI/comfy/samplers.py", line 228, in calc_cond_batch
output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
File "/root/ComfyUI/custom_nodes/ComfyUI-Advanced-ControlNet/adv_control/utils.py", line 68, in apply_model_uncond_cleanup_wrapper
return orig_apply_model(self, *args, **kwargs)
File "/root/ComfyUI/comfy/model_base.py", line 145, in apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/root/ComfyUI/comfy/ldm/flux/model.py", line 150, in forward
out = self.forward_orig(img, img_ids, context, txt_ids, timestep, y, guidance, control)
File "/root/ComfyUI/comfy/ldm/flux/model.py", line 129, in forward_orig
img = block(img, vec=vec, pe=pe)
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/root/ComfyUI/comfy/ldm/flux/layers.py", line 233, in forward
output = self.linear2(torch.cat((attn, self.mlp_act(mlp)), 2))
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib64/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/root/ComfyUI/comfy/ops.py", line 63, in forward
return self.forward_comfy_cast_weights(*args, **kwargs)
File "/root/ComfyUI/comfy/ops.py", line 58, in forward_comfy_cast_weights
weight, bias = cast_bias_weight(self, input)
File "/root/ComfyUI/comfy/ops.py", line 42, in cast_bias_weight
weight = cast_to(s.weight, dtype, device, non_blocking=non_blocking)
File "/root/ComfyUI/comfy/ops.py", line 24, in cast_to
return weight.to(device=device, dtype=dtype, non_blocking=non_blocking)
```
```
### Other
```
comfyui-rocm | [INFO] Running set-proxy script...
comfyui-rocm | [INFO] Continue without proxy.
comfyui-rocm | [INFO] Running pre-start script...
comfyui-rocm | [INFO] Continue without pre-start script.
comfyui-rocm | ########################################
comfyui-rocm | [INFO] Starting ComfyUI...
comfyui-rocm | ########################################
comfyui-rocm | [ComfyUI-Manager] 'distutils' package not found. Activating fallback mode for compatibility.
comfyui-rocm | [START] Security scan
comfyui-rocm | [DONE] Security scan
comfyui-rocm | ## ComfyUI-Manager: installing dependencies done.
comfyui-rocm | ** ComfyUI startup time: 2024-08-13 19:33:29.232847
comfyui-rocm | ** Platform: Linux
comfyui-rocm | ** Python version: 3.10.14 (main, Mar 21 2024, 16:45:28) [GCC]
comfyui-rocm | ** Python executable: /usr/bin/python3
comfyui-rocm | ** ComfyUI Path: /root/ComfyUI
comfyui-rocm | ** Log path: /root/comfyui.log
comfyui-rocm |
comfyui-rocm | Prestartup times for custom nodes:
comfyui-rocm | 0.5 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Manager
comfyui-rocm |
comfyui-rocm | Total VRAM 512 MB, total RAM 47379 MB
comfyui-rocm | pytorch version: 2.1.2+rocm6.1.3
comfyui-rocm | Set vram state to: LOW_VRAM
comfyui-rocm | Device: cuda:0 AMD Radeon Graphics : native
comfyui-rocm | Using split optimization for cross attention
comfyui-rocm | [Prompt Server] web root: /root/ComfyUI/web
comfyui-rocm | ### Loading: ComfyUI-Manager (V2.48.7)
comfyui-rocm | ### ComfyUI Revision: 174 [39fb74c5] | Released on '2024-08-13'
comfyui-rocm | [Crystools INFO] Crystools version: 1.16.6
comfyui-rocm | [Crystools INFO] CPU: AMD Ryzen 7 7700 8-Core Processor - Arch: x86_64 - OS: Linux 6.1.0-18-amd64
comfyui-rocm | [Crystools ERROR] Could not init pynvml (Nvidia).NVML Shared Library Not Found
comfyui-rocm | [Crystools WARNING] No GPU with CUDA detected.
Efficiency Nodes: Attempting to add Control Net options to the 'HiRes-Fix Script' Node (comfyui_controlnet_aux add-on)...Success!
comfyui-rocm | ### Loading: ComfyUI-Impact-Pack (V6.2)
comfyui-rocm | ### Loading: ComfyUI-Impact-Pack (Subpack: V0.6)
comfyui-rocm | [Impact Pack] Wildcards loading done.
comfyui-rocm | ### Loading: ComfyUI-Inspire-Pack (V0.83)
comfyui-rocm | [AnimateDiffEvo] - ERROR - No motion models found. Please download one and place in: ['/root/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models', '/root/ComfyUI/models/animatediff_models']
comfyui-rocm |
comfyui-rocm | Import times for custom nodes:
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/websocket_image_save.py
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Crystools-save
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/sdxl_prompt_styler
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/cg-use-everywhere
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/comfyui_controlnet_aux
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/AIGODLIKE-ComfyUI-Translation
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI_IPAdapter_plus
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Frame-Interpolation
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Advanced-ControlNet
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Manager
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI_essentials
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved
comfyui-rocm | 0.0 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Inspire-Pack
comfyui-rocm | 0.1 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Crystools
comfyui-rocm | 0.1 seconds: /root/ComfyUI/custom_nodes/ComfyUI-Impact-Pack
comfyui-rocm | 0.3 seconds: /root/ComfyUI/custom_nodes/ComfyUI-VideoHelperSuite
comfyui-rocm | 0.4 seconds: /root/ComfyUI/custom_nodes/efficiency-nodes-comfyui
comfyui-rocm |
comfyui-rocm | Starting server
comfyui-rocm |
comfyui-rocm | To see the GUI go to: http://0.0.0.0:8188
comfyui-rocm | FETCH DATA from: /root/ComfyUI/custom_nodes/ComfyUI-Manager/extension-node-map.json [DONE]
comfyui-rocm | got prompt
comfyui-rocm | model weight dtype torch.bfloat16, manual cast: None
comfyui-rocm | model_type FLOW
comfyui-rocm | /usr/local/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
comfyui-rocm | warnings.warn(
comfyui-rocm | Requested to load FluxClipModel_
comfyui-rocm | Loading 1 new model
comfyui-rocm | clip missing: ['text_projection.weight']
comfyui-rocm | Requested to load Flux
comfyui-rocm | Loading 1 new model
comfyui-rocm | loaded partially 64.0 60.7852783203125 0
0%| | 0/4 [01:11
Contributor guide
Assessment
This issue has not been assessed yet.