mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-07-10 01:18:32 +00:00
allow SD to limit max VRAM usage
This commit is contained in:
parent
485113f74c
commit
c3246cd392
2 changed files with 8 additions and 1 deletions
|
|
@ -2478,6 +2478,7 @@ def sd_load_model(model_filename,vae_filename,t5xxl_filename,clip1_filename,clip
|
|||
inputs.clip2_filename = clip2_filename.encode("UTF-8")
|
||||
inputs.photomaker_filename = photomaker_filename.encode("UTF-8")
|
||||
inputs.upscaler_filename = upscaler_filename.encode("UTF-8")
|
||||
inputs.max_vram = (args.sdvramlimit/1024.0) if args.sdvramlimit > 0 else 0
|
||||
|
||||
lora_filenames, lora_multipliers = prepare_initial_lora_multipliers()
|
||||
inputs.lora_len = len(lora_filenames)
|
||||
|
|
@ -7709,6 +7710,7 @@ def show_gui():
|
|||
sd_threads_var = ctk.StringVar(value=str(default_threads))
|
||||
sd_quant_var = ctk.StringVar(value=sd_quant_choices[0])
|
||||
sd_main_gpu_var = ctk.StringVar(value="main")
|
||||
sd_vram_limit_var = ctk.StringVar(value="")
|
||||
|
||||
gen_defaults_var = ctk.StringVar()
|
||||
gen_defaults_overwrite_var = ctk.IntVar(value=0)
|
||||
|
|
@ -8639,6 +8641,8 @@ def show_gui():
|
|||
makecheckbox(images_tab, "Model Offload", sd_offload_cpu_var, 50,padx=8, tooltiptxt="Offload image weights in RAM to save VRAM, swap into VRAM when needed.")
|
||||
makelabelcombobox(images_tab, "VAE dev:", sd_vae_device_var, 50,labelpadx=(140),padx=(200), width=70, tooltiptxt="Change VAE device for image generation.", values=sd_device_choices)
|
||||
makelabelcombobox(images_tab, "CLIP dev:", sd_clip_device_var, 50,labelpadx=(280),padx=340, width=70, tooltiptxt="Change CLIP / T5 / LLM device for image generation.", values=sd_device_choices)
|
||||
makelabelentry(images_tab, "VRAM Limiter (MB):", sd_vram_limit_var, 60, 50, padx=(144),singleline=True,tooltip="If set, prevent VRAM usage from image gen from using more than this many MB.")
|
||||
|
||||
|
||||
# audio tab
|
||||
audio_tab = tabcontent["Audio"]
|
||||
|
|
@ -8970,6 +8974,7 @@ def show_gui():
|
|||
args.sdvaedevice = sd_resolve_device(sd_vae_device_var.get())
|
||||
args.sdclipdevice = sd_resolve_device(sd_clip_device_var.get())
|
||||
args.sdthreads = (0 if sd_threads_var.get()=="" else int(sd_threads_var.get()))
|
||||
args.sdvramlimit = (0 if sd_vram_limit_var.get()=="" else int(sd_vram_limit_var.get()))
|
||||
args.sdclamped = (0 if int(sd_clamped_var.get())<=0 else int(sd_clamped_var.get()))
|
||||
args.sdclampedsoft = (0 if int(sd_clamped_soft_var.get())<=0 else int(sd_clamped_soft_var.get()))
|
||||
args.sdtiledvae = (default_vae_tile_threshold if sd_tiled_vae_var.get()=="" else int(sd_tiled_vae_var.get()))
|
||||
|
|
@ -9291,6 +9296,7 @@ def show_gui():
|
|||
sd_runtime_loras_var.set(1)
|
||||
else:
|
||||
sd_runtime_loras_var.set(0)
|
||||
sd_vram_limit_var.set(str(mydict["sdvramlimit"]) if ("sdvramlimit" in mydict and mydict["sdvramlimit"]) else "")
|
||||
|
||||
gendefaults = (mydict["gendefaults"] if ("gendefaults" in mydict and mydict["gendefaults"]) else "")
|
||||
if isinstance(gendefaults, type({})):
|
||||
|
|
@ -11828,6 +11834,7 @@ if __name__ == '__main__':
|
|||
sdparsergroup.add_argument("--sdloramult", metavar=('[amounts]'), help="Multipliers for the image LoRA model to be applied.", type=float, nargs='+', default=[1.0])
|
||||
sdparsergroup.add_argument("--sdtiledvae", metavar=('[maxres]'), help="Adjust the automatic VAE tiling trigger for images above this size. 0 disables vae tiling.", type=int, default=default_vae_tile_threshold)
|
||||
sdparsergroup.add_argument("--sdmaingpu", metavar=('[Device ID]'), help="If specified, Image Generation weights will be placed on the selected GPU index. GPU index, -1 or 'main' for the main GPU, or 'CPU' (default: 'main')", type=sd_get_device_number, default=None)
|
||||
sdparsergroup.add_argument("--sdvramlimit", metavar=('[limit MB]'), help="If set, prevent VRAM usage from image gen from using more than this many MB.", type=int, default=0)
|
||||
|
||||
whisperparsergroup = parser.add_argument_group('Whisper Transcription Commands')
|
||||
whisperparsergroup.add_argument("--whispermodel", metavar=('[filename]'), help="Specify a Whisper .bin model to enable Speech-To-Text transcription.", default="")
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ bool sdtype_load_model(const sd_load_model_inputs inputs) {
|
|||
printf("Using mmap for I/O\n");
|
||||
}
|
||||
if(inputs.max_vram != 0.f) {
|
||||
printf("Using max VRAM = %0.2f\n", inputs.max_vram);
|
||||
printf("Using max VRAM = %0.2f GB\n", inputs.max_vram);
|
||||
}
|
||||
if(inputs.quant > 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue