lllyasviel / lllyasviel/stable-diffusion-webui-forge

LoRA reloaded more and more times during batch processing

Open
#2,209 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

I'm running img2img with batch processing on a directory, using the Ultimate SD upscale script with a SDXL model. My prompt, which I saved in Styles, contains just a LoRA in the positive.

For every new tile of every image, the LoRA gets loaded an extra time, growing to take a significant amount of time as multiple files are processed. This is what I see in the console:

```
Image size: 1280x720
Scale factor: 3
Upscaling iteration 1 with scale factor 3
[Unload] Trying to free 1024.00 MB for cuda:0 with 0 models keep loaded ... Current free memory is 7422.01 MB ... Done.
Cleanup minimal inference memory.
tiled upscale: 100%|####################################################################################################################################################| 28/28 [00:02<00:00, 11.78it/s]
Tile size: 1024x1024
Tiles amount: 12
Grid: 3x4
Redraw enabled: True
Seams fix mode: NONE
[Unload] Trying to free 3989.55 MB for cuda:0 with 1 models keep loaded ... Current free memory is 7394.92 MB ... Done.
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
```

...the above one line repeats a total of 144 times, and right after, there's this:

```
[Unload] Trying to free 1024.00 MB for cuda:0 with 1 models keep loaded ... Current free memory is 7395.51 MB ... Done.
[Textual Inversion] Used Embedding [XL-NEG-XL_D] in CLIP of [clip_l]
[Textual Inversion] Used Embedding [XL-NEG-XL_D] in CLIP of [clip_g]
[Unload] Trying to free 1024.00 MB for cuda:0 with 1 models keep loaded ... Current free memory is 7395.51 MB ... Done.
[Unload] Trying to free 3071.22 MB for cuda:0 with 0 models keep loaded ... Current free memory is 7395.24 MB ... Done.
[Memory Management] Target: KModel, Free GPU: 7395.24 MB, Model Require: 0.00 MB, Previously Loaded: 4897.05 MB, Inference Require: 1024.00 MB, Remaining: 6371.24 MB, All loaded to GPU.
Moving model(s) has taken 0.02 seconds
100%|#####################################################################################################################################################################| 3/3 [00:00<00:00, 3.92it/s]
[Unload] Trying to free 4917.52 MB for cuda:0 with 1 models keep loaded ... Current free memory is 7422.39 MB ... Done. | 3/36 [00:00<00:05, 5.61it/s]
[Unload] Trying to free 1024.00 MB for cuda:0 with 0 models keep loaded ... Current free memory is 7400.61 MB ... Done.
Cleanup minimal inference memory.
tiled upscale: 100%|####################################################################################################################################################| 36/36 [00:03<00:00, 11.75it/s]
[Unload] Trying to free 3989.55 MB for cuda:0 with 1 models keep loaded ... Current free memory is 7378.64 MB ... Done.
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
[LORA] Loaded /opt/sd-forge/models/Lora/MoreArtFull.safetensors for KModel-UNet with 788 keys at weight 1.1 (skipped 0 keys) with on_the_fly = False
```

...the above line repeats a total of 145 times. And so on.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce img2img batch processing with Ultimate SD upscale, an SDXL model, and a Styles prompt containing one LoRA, then use the console's repeated LoRA load lines as the baseline. Trace when the LoRA is loaded for each tile and image; done means processing no longer reloads the same LoRA increasingly often while preserving the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.