Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/sd_offload.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,11 @@ def do_move(module):
op = f'{op}:always'
module = do_move(module)
used_gpu -= module_size
elif perc_gpu > shared.opts.diffusers_offload_min_gpu_memory:
# only offload under genuine memory pressure: if the whole working set already fits within the
# GPU budget (diffusers_offload_max_gpu_memory) then offloading here just forces a costly
# re-onload on the module's next forward -- e.g. the UNet evicted to run the text encoder / VAE
# then re-dispatched every generation (~2x slowdown on cards with spare VRAM).
elif perc_gpu > shared.opts.diffusers_offload_min_gpu_memory and offload_hook_instance.model_size() > offload_hook_instance.gpu / (1024 ** 3):
op = f'{op}:mem'
module = do_move(module)
used_gpu -= module_size
Expand Down
Loading