Speedup Stable diffusion model Loading time

A1111 Webui

webui-user.bat
set COMMANDLINE_ARGS= --xformers --no-hashing --opt-channelslast --no-download-sd-model --lowram
set SAFETENSORS_FAST_GPU=1

stable-diffusion-webui/modules/sd_models.py
Switch
pl_sd = safetensors.torch.load_file(checkpoint_file, device=device)
by
pl_sd = safetensors.torch.load(open(checkpoint_file, 'rb').read())

pl_sd = safetensors.torch.load(open(checkpoint_file, 'rb').read())
pl_sd = {k: v.to(device) for k, v in pl_sd.items()}

Comfyui

Comfyui/Comfyui/comfy/utils.pyreplacing
sd = safetensors.torch.load_file(ckpt, device=device.type)
by
sd = safetensors.torch.load(open(ckpt, 'rb').read())

It will increased the speed from the HDD x6 times, from 15M/s to 200MB/s

Setting custom filenames in Stable Diffusion – Comfyui and Automatic1111 webui

The Stable Diffusion ComfyUI is a powerful GUI for AI image generation, but it’s also known for its limited documentation and steep learning curve for automatic1111 users.

By default, ComfyUI generated images will be dumped in the output folder with the meaningless filename ComfyUI_00001_.png with increasing numbers.

Continue reading “Setting custom filenames in Stable Diffusion – Comfyui and Automatic1111 webui”

How to share model and settings when multiple sets of Stable Diffusion

I have three sets of Stable Diffusion ui installed on my computer:

  • a1111 webui
  • comfyui
  • 秋叶整合包( An integrated package of SD webui)

There are a bunch of large models, LoRA, ControlNet, plus some VAE, upscale enlargement models, etc. The ones I commonly use are about 90G. Copying three copies takes up a lot of space, and updating the version is also troublesome.

You can put all the models in one location, and then specify the model location for each SD UI.

There are usually two methods:
Mklink and Command line parameters.

1. Mklink (symbolic link)

It is similar to a folder pointer or shortcut, which allows the model folders of each SD UI, such as models, to point to the same centrally stored model folder.

Example, use mklink to create a symbolic link to point the A directory on the C drive to the B directory on the D drive:

mklink /d C:\XXX\A D:\XXX\B

Microsoft mklink documentation:

https://learn.microsoft.com/zh-cn/windows-server/administration/windows-commands/mklink

For example my model folder is:

D:\ai\models\sd\webui_using

Some commonly used model files are classified under this folder:

Continue reading “How to share model and settings when multiple sets of Stable Diffusion”