lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
8.6k stars 849 forks source link

LoRA reloaded more and more times during batch processing #2209

Open mprz1024 opened 4 weeks ago

mprz1024 commented 4 weeks ago

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.

derpina-ai commented 3 weeks ago

Use Automatic Fp16 Lora setting.