CivArchive
    SDXL LoRA train(8GB) and Checkpoint finetune(16GB) - v4.5
    NSFW
    Preview 1990948

    Credit:

    This script package from bdsqlsz

    use kohya-ss/sd-scripts (github.com) for core

    original script from Akegarasu/lora-scripts: LoRA training scripts use kohya-ss's trainer, for diffusion model. (github.com)

    How to use:

    0、(windows)Give unrestricted script access to powershell so venv can work:

    • Open an administrator powershell window

    • Type Set-ExecutionPolicy Unrestricted and answer A

    • Close admin powershell window

    1、Unzip this to anyway you want(Recommend with other train program which has venv)

    if you Update it,just Rerun install-cn-qinglong.ps1.then enter N

    2、Run install-cn-qinglong.ps1 in windows(linux just use commnd line)

    it will automatically install environment(if you has venv,just put to over it)

    3、Put your datesets in /input dir.

    a formattting:
    ./input/2_lora/(datasets images)

    4、Run tagger.ps1 for tagger them,automatically.(linux use tagger.sh)

    5、Edit your datesets if your want

    6、Edit train script(train_8Glora or train_16G_DB)(linux use train_tacanime)

    just for

    1. train_mode(lora、db、sdxl_lora、sdxl_db、cn3l)

    2. pretrained_model

    3. train_data_dir

      a formatting ./input/

    4. resolution(SDXL for 1024*1024,sd1.5 for 576*576)

    5. max and min bucket repo(SDXL 640~1536,sd1.5:256~1024)

    6. optimizer(SDXL:adaFactor for batch size1,Pagedadamw8bit for batch size 4)

    other dont need more change if you dont know it

    if i can help you ,i will very happy that~

    Support 青龍聖者@bdsqlsz on Ko-fi! ❤️. ko-fi.com/bdsqlsz - Ko-fi ❤️ Where creators get support from fans through donations, memberships, shop sales and more! The original 'Buy Me a Coffee' Page.

    Description

    fix install bugs

    FAQ

    Comments (8)

    GPUPoorChadAug 11, 2023
    CivitAI

    Copy-Item: C:\Users\****\Downloads\sdxlLoraTrain8GBAnd_v40\install-cn-qinglong.ps1:57

    Line |

    57 | cp .\bitsandbytes_windows\functional.py ..\venv\Lib\site-packages\bit …

    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    | Cannot find path 'C:\Users\****\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\bitsandbytes_windows\functional.py'

    | because it does not exist.

    GPUPoorChadAug 12, 2023

    I was able to copy a file that I think is what it wanted

    bdsqlsz
    Author
    Aug 12, 2023

    i fixed it now.

    GPUPoorChadAug 12, 2023
    CivitAI
    loading VAE from checkpoint VAE: <All keys matched successfully> Enable xformers for U-Net import network module: networks.lora [Dataset 0] caching latents. checking cache validity... 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 52/52 [00:00<00:00, 51941.85it/s] caching latents... 0%| | 0/25 [00:03<?, ?it/s] Traceback (most recent call last): File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\sdxl_train_network.py", line 174, in <module> trainer.train(args) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\train_network.py", line 252, in train train_dataset_group.cache_latents(vae, args.vae_batch_size, args.cache_latents_to_disk, accelerator.is_main_process) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\library\train_util.py", line 1821, in cache_latents dataset.cache_latents(vae, vae_batch_size, cache_to_disk, is_main_process) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\library\train_util.py", line 870, in cache_latents cache_batch_latents(vae, cache_to_disk, batch, subset.flip_aug, subset.random_crop) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\sd-scripts\library\train_util.py", line 2157, in cache_batch_latents raise RuntimeError(f"NaN detected in latents: {info.absolute_path}") RuntimeError: NaN detected in latents: C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\input\2_pipkinpippa\7609786.png Traceback (most recent call last): File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Python310\lib\runpy.py", line 86, in run_code exec(code, run_globals) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\venv\Scripts\accelerate.exe_main.py", line 7, in <module> File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main args.func(args) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\venv\lib\site-packages\accelerate\commands\launch.py", line 918, in launch_command simple_launcher(args) File "C:\Users[username]\Downloads\sdxlLoraTrain8GBAnd_v40\venv\lib\site-packages
    bdsqlsz
    Author
    Aug 12, 2023

    RuntimeError: NaN detected in latents...

    i think it makes error in cache latent

    GPUPoorChadAug 12, 2023

    @bdsqlsz Strange, all I did really was change it from bf16 to fp16 because my GPU is older

    GPUPoorChadAug 12, 2023
    CivitAI

    Can install.bat be used instead? The install script suggested uses Baidu mirrors in China, as I live half way across the world (United States) it is very slow. The normal Install script seemed to have some lines missing that looked important

    bdsqlsz
    Author
    Aug 13, 2023

    ill add for us,you can use install.ps1

    Other
    SDXL 1.0

    Details

    Downloads
    196
    Platform
    CivitAI
    Platform Status
    Available
    Created
    8/12/2023
    Updated
    5/13/2026
    Deleted
    -

    Files

    sdxlLoraTrain8GBAnd_v45.zip

    Mirrors

    CivitAI (1 mirrors)

    Available On (1 platform)

    Same model published on other platforms. May have additional downloads or version variants.