wan2.1 i2v模型 24G 4090D上, fp16权重加--disable-cuda-malloc不会爆显存,但是fp8权重加--disable-cuda-malloc会爆显存这是为什么?
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 155
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
不爆显存
### Actual Behavior
爆显存
### Steps to Reproduce
工作流如下:
[wan2.1_i2v.json](https://github.com/user-attachments/files/22019211/wan2.1_i2v.json)
### Debug Logs
```powershell
!!! Exception during processing !!! CUDA out of memory. Tried to allocate 640.00 MiB. GPU 0 has a total capacity of 23.53 GiB of which 144.75 MiB is free. Process 3870133 has 23.38 GiB memory in use. Of the allocated memory 19.52 GiB is allocated by PyTorch, and 3.44 GiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
Traceback (most recent call last):
File "/workspace/ComfyUI/execution.py", line 501, 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 "/workspace/ComfyUI/execution.py", line 315, 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 "/workspace/ComfyUI/execution.py", line 289, in _async_map_node_over_list
await process_inputs(input_dict, i)
File "/workspace/ComfyUI/execution.py", line 277, in process_inputs
result = f(**inputs)
File "/workspace/ComfyUI/nodes.py", line 1521, in sample
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
File "/workspace/ComfyUI/nodes.py", line 1488, in common_ksampler
samples = comfy.sample.sample(model, noise, steps, cfg, sampler_name, scheduler, positive, negative, latent_image,
File "/workspace/ComfyUI/comfy/sample.py", line 45, 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 "/workspace/ComfyUI/comfy/samplers.py", line 1161, 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 "/workspace/ComfyUI/comfy/samplers.py", line 1051, in sample
return cfg_guider.sample(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/workspace/ComfyUI/comfy/samplers.py", line 1036, in sample
output = executor.execute(noise, latent_image, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/samplers.py", line 1004, in outer_sample
output = self.inner_sample(noise, latent_image, device, sampler, sigmas, denoise_mask, callback, disable_pbar, seed)
File "/workspace/ComfyUI/comfy/samplers.py", line 987, in inner_sample
samples = executor.execute(self, sigmas, extra_args, callback, noise, latent_image, denoise_mask, disable_pbar)
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/samplers.py", line 759, in sample
samples = self.sampler_function(model_k, noise, sigmas, extra_args=extra_args, callback=k_callback, disable=disable_pbar, **self.extra_options)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 868, in sample_unipc
x = uni_pc.sample(noise, timesteps=timesteps, skip_type="time_uniform", method="multistep", order=order, lower_order_final=True, callback=callback, disable_pbar=disable)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 715, in sample
model_prev_list = [self.model_fn(x, vec_t)]
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 410, in model_fn
return self.data_prediction_fn(x, t)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 394, in data_prediction_fn
noise = self.noise_prediction_fn(x, t)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 388, in noise_prediction_fn
return self.model(x, t)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 329, in model_fn
return noise_pred_fn(x, t_continuous)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 297, in noise_pred_fn
output = model(x, t_input, **model_kwargs)
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 859, in
lambda input, sigma, **kwargs: predict_eps_sigma(model, input, sigma, **kwargs),
File "/workspace/ComfyUI/comfy/extra_samplers/uni_pc.py", line 843, in predict_eps_sigma
return (input - model(input, sigma_in, **kwargs)) / sigma
File "/workspace/ComfyUI/comfy/samplers.py", line 408, in __call__
out = self.inner_model(x, sigma, model_options=model_options, seed=seed)
File "/workspace/ComfyUI/comfy/samplers.py", line 960, in __call__
return self.outer_predict_noise(*args, **kwargs)
File "/workspace/ComfyUI/comfy/samplers.py", line 967, in outer_predict_noise
).execute(x, timestep, model_options, seed)
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/samplers.py", line 970, 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 "/workspace/ComfyUI/comfy/samplers.py", line 388, in sampling_function
out = calc_cond_batch(model, conds, x, timestep, model_options)
File "/workspace/ComfyUI/comfy/samplers.py", line 206, in calc_cond_batch
return _calc_cond_batch_outer(model, conds, x_in, timestep, model_options)
File "/workspace/ComfyUI/comfy/samplers.py", line 214, in _calc_cond_batch_outer
return executor.execute(model, conds, x_in, timestep, model_options)
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/samplers.py", line 333, in _calc_cond_batch
output = model.apply_model(input_x, timestep_, **c).chunk(batch_chunks)
File "/workspace/ComfyUI/comfy/model_base.py", line 156, in apply_model
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/model_base.py", line 195, in _apply_model
model_output = self.diffusion_model(xc, t, context=context, control=control, transformer_options=transformer_options, **extra_conds).float()
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
File "/workspace/ComfyUI/comfy/ldm/wan/model.py", line 602, in forward
return comfy.patcher_extension.WrapperExecutor.new_class_executor(
File "/workspace/ComfyUI/comfy/patcher_extension.py", line 112, in execute
return self.original(*args, **kwargs)
File "/workspace/ComfyUI/comfy/ldm/wan/model.py", line 622, in _forward
return self.forward_orig(x, timestep, context, clip_fea=clip_fea, freqs=freqs, transformer_options=transformer_options, **kwargs)[:, :, :t, :h, :w]
File "/workspace/ComfyUI/comfy/ldm/wan/model.py", line 567, in forward_orig
x = block(x, e=e0, freqs=freqs, context=context, context_img_len=context_img_len)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
File "/workspace/ComfyUI/comfy/ldm/wan/model.py", line 225, in forward
y = self.self_attn(
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1751, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1762, in _call_impl
return forward_call(*args, **kwargs)
File "/workspace/ComfyUI/comfy/ldm/wan/model.py", line 71, in forward
q, k = apply_rope(q, k, freqs)
File "/workspace/ComfyUI/comfy/ldm/flux/math.py", line 42, in apply_rope
xq_out = freqs_cis[..., 0] * xq_[..., 0] + freqs_cis[..., 1] * xq_[..., 1]
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 640.00 MiB. GPU 0 has a total capacity of 23.53 GiB of which 144.75 MiB is free. Process 3870133 has 23.38 GiB memory in use. Of the allocated memory 19.52 GiB is allocated by PyTorch, and 3.44 GiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
```
### Other
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.