sd-scripts English / 日本語 Table of Contents <details <summaryClick to expand</summary - Introduction - Supported Models - Features - Sponsor…
sd-scripts English / 日本語 Table of Contents <details <summaryClick to expand</summary - Introduction - Supported Models - Features - Sponsor…
This repository contains training, generation and utility scripts for Stable Diffusion and other image generation models.
We are grateful to the following companies for their generous sponsorship:
If you find this project helpful, please consider supporting its development via GitHub Sponsors. Your support is greatly appreciated!
Changes planned for the next release: The following are the main changes planned for the next release. Please note that these changes may be subject to change without notice before the release.
networks.oft_v2, networks.boft) for SD1.x / SD2.x / SDXL training. PR #2357--network_dim means the block size for these modules. For details, please refer to the documentation.custom_attributes.timestep_sampling.offset) for FLUX.1 and Anima LoRA training. PR #2401 Thanks to okdsf.--show_timesteps_offset to preview the timestep distribution with the offset applied when using --show_timesteps. PR #2410shift / flux_shift timestep sampling.Version 0.11.1 (2026-06-16):
--qwen_image_vae_2d. The weights are the same as the standard (3D) version.Version 0.11.0 (2026-06-12):
Version 0.10.6 (2026-06-12):
Version 0.10.5 (2026-05-08):
transformers version in requirements.txt remains 4.x, but it also works with 5.x. If you use 5.x for any reason, please also update diffusers to the latest version.Version 0.10.4 (2026-05-07):
This repository provides recommended instructions to help AI agents like Claude and Gemini understand our project context and coding standards.
To use them, you need to opt-in by creating your own configuration file in the project root.
Quick Setup:
Create a CLAUDE.md and/or GEMINI.md file in the project root.
Add the following line to your CLAUDE.md to import the repository's recommended prompt:
@./.ai/claude.prompt.mdor for Gemini:
@./.ai/gemini.prompt.mdYou can now add your own personal instructions below the import line (e.g., Always respond in Japanese.).
This approach ensures that you have full control over the instructions given to your agent while benefiting from the shared project context. Your CLAUDE.md and GEMINI.md are already listed in .gitignore, so they won't be committed to the repository.
Python 3.10.x and Git:
Python 3.11.x, and 3.12.x will work but not tested.
Give unrestricted script access to powershell so venv can work:
Set-ExecutionPolicy Unrestricted and answer AOpen a regular Powershell terminal and type the following inside:
git clone https://github.com/kohya-ss/sd-scripts.git
cd sd-scripts
python -m venv venv
.\venv\Scripts\activate
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
pip install --upgrade -r requirements.txt
accelerate configIf python -m venv shows only python, change python to py.
Note: bitsandbytes, prodigyopt and lion-pytorch are included in the requirements.txt. If you'd like to use another version, please install it manually.
This installation is for CUDA 12.4. If you use a different version of CUDA, please install the appropriate version of PyTorch. For example, if you use CUDA 12.1, please install pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu121.
Answers to accelerate config:
- This machine
- No distributed training
- NO
- NO
- NO
- all
- fp16If you'd like to use bf16, please answer bf16 to the last question.
Note: Some user reports ValueError: fp16 mixed precision requires a GPU is occurred in training. In this case, answer 0 for the 6th question:
What GPU(s) (by id) should be used for training on this machine as a comma-separated list? [all]:
(Single GPU with id 0 will be used.)
The file does not contain requirements for PyTorch. Because the version of PyTorch depends on the environment, it is not included in the file. Please install PyTorch first according to the environment. See installation instructions below.
The scripts are tested with PyTorch 2.6.0. PyTorch 2.6.0 or later is required.
For RTX 50 series GPUs, PyTorch 2.8.0 with CUDA 12.8/12.9 should be used. requirements.txt will work with this version.
To install xformers, run the following command in your activated virtual environment:
pip install xformers --index-url https://download.pytorch.org/whl/cu124Please change the CUDA version in the URL according to your environment if necessary. xformers may not be available for some GPU architectures.
Linux or WSL2 installation steps are almost the same as Windows. Just change venv\Scripts\activate to source venv/bin/activate.
Note: Please make sure that NVIDIA driver and CUDA toolkit are installed in
Crashed randomly in the middle of cooking
`torch.cuda.amp` in `__main__` self-test blocks and the IPEX hijack — deprecated since torch 2.3/2.4, unguarded on the main install path
[Feature Request] Add option to disable cuDNN/MIOpen backend (workaround for AMD RDNA 4 GPU crashes)
WeightsUnpickler error: Unsupported operand 56
--tag_replacement doesn't actually replace anything (variable shadowing bug)
[bug] --skip_until_initial_step 使用時、--gradient_accumulation_steps > 1 で再開位置を過剰にスキップして学習が終了する
Silent `adaln` drop while anima lora training
LECO: verify_training_args() crashes on missing sample_every_n_epochs/sample_every_n_steps
Adding Anima ControlNet support
"Missing keys in state dict" solved when training lora on some anima ft checkpoints