Go to file
Claude 5b3d3ab806
Fix Docker setup issues and rewrite README.md
Identified and documented 12+ critical issues with Docker setup:
- Missing docker.md documentation (broken link in README)
- Duplicate volume mounts in docker-compose.yaml
- Hard-coded UID causing permission issues
- No health checks or restart policies
- Oversized TensorBoard image
- Missing resource limits and .env documentation
- Platform support ambiguities

Created comprehensive Docker documentation (docs/docker.md):
- Complete prerequisites for Windows/Linux/macOS
- Detailed setup and troubleshooting guides
- Configuration examples and best practices
- Advanced usage patterns (multi-GPU, resource limits)
- Security and performance tips

Rewrote README.md with improved structure:
- Better organization with clear navigation
- Fixed broken docker.md link
- Enhanced Docker installation section
- Improved quick start guide with comparison table
- Expanded troubleshooting section
- Better formatting and readability
- Added quick reference section
2026-01-04 21:07:49 +00:00
.cache Docker: empty directories for docker volumes 2023-06-12 17:02:19 +03:00
.github Bump crate-ci/typos from 1.31.2 to 1.32.0 2025-06-01 05:40:31 +00:00
.vscode Restructure files 2024-04-03 19:36:02 -04:00
assets Update style 2025-05-26 08:50:23 -04:00
config_files/accelerate Remove torch 1 support from code 2023-10-04 19:00:12 -04:00
dataset refactor: build `dataset` directory structure 2024-03-15 12:44:48 +08:00
docs Fix Docker setup issues and rewrite README.md 2026-01-04 21:07:49 +00:00
examples v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
kohya_gui Revert "feat: Remember last used folder for file dialogs (#3290)" 2025-06-17 10:07:04 -04:00
localizations Bump crate-ci/typos from 1.18.2 to 1.19.0 (#2189) 2024-04-01 11:20:45 -04:00
models Add support for user managed path config 2024-03-16 20:58:22 -04:00
presets v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
sd-scripts@3e6935a07e Docs python version uv (#3289) 2025-06-16 07:28:39 -04:00
setup Core improvements batch1 (#3294) 2025-06-19 08:07:05 -04:00
test Add pytorch_optimizer.CAME to optimizer list. 2025-03-30 14:44:24 -04:00
tools Cleanup files 2025-05-27 08:47:38 -04:00
.augmentignore Dev pure (#2039) 2024-03-09 09:30:20 -05:00
.dockerignore v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
.env chore(docker): Configure TensorBoard port through .env file (#2397) 2024-04-26 19:43:37 -04:00
.gitattributes Address issue 188 2023-04-15 08:52:23 -04:00
.gitignore Ignore .python-version changes 2025-06-16 07:11:31 -04:00
.gitmodules Dev pure (#2039) 2024-03-09 09:30:20 -05:00
.hadolint.yml chore(docker): rewrite Dockerfile 2024-02-18 09:58:59 +08:00
.python-version Update python verstion to 3.11 2025-06-16 07:10:02 -04:00
.release Update release 2025-06-23 08:35:07 -04:00
Dockerfile build(docker): upgrade to CUDA 12.8 and Debian 12 2025-05-27 00:19:05 +08:00
LICENSE.md Add support for new arguments: 2023-01-15 11:05:22 -05:00
README.md Fix Docker setup issues and rewrite README.md 2026-01-04 21:07:49 +00:00
SECURITY.md Update SECURITY.md 2024-04-11 09:02:21 -04:00
_typos.toml v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
config example.toml v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
docker-compose.yaml v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
gui-uv.bat Update how uv is installed on windows 2025-05-25 19:16:58 -04:00
gui-uv.sh Add message when --quiet is used 2025-05-26 18:39:36 -04:00
gui.bat Merge branch 'master' into dev 2025-03-28 11:20:53 -04:00
gui.ps1 v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
gui.sh It looks like the setup.sh and gui.sh scripts were incorrectly defaulting to ROCm package installation if `rocminfo` was present, even on systems with NVIDIA GPUs. (#3293) 2025-06-18 19:52:40 -04:00
kohya_gui.py v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
pyproject.toml Update release 2025-06-23 08:35:07 -04:00
requirements.txt Fix bad commit 2025-06-19 19:53:15 -04:00
requirements_ipex_xpu.txt Update IPEX and ROCm 2025-06-13 20:17:05 +03:00
requirements_linux.txt Fix requirements issues 2025-05-26 21:33:06 -04:00
requirements_linux_ipex.txt Cleanup 2025-06-13 20:31:42 +03:00
requirements_linux_rocm.txt Update IPEX and ROCm 2025-06-13 20:17:05 +03:00
requirements_macos_amd64.txt v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
requirements_macos_arm64.txt Apple Silicone Support (This time not on Master) (#3174) 2025-04-19 10:22:53 -04:00
requirements_pytorch_windows.txt Update requirements file for 50X0 support 2025-05-26 07:11:25 -04:00
requirements_runpod.txt v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
requirements_windows.txt Update requirements file for 50X0 support 2025-05-26 07:11:25 -04:00
setup-3.10.bat v25.0.0 release (#3138) 2025-03-28 11:00:44 -04:00
setup-runpod.sh Improve setup. Add --headless option 2024-03-12 20:31:22 -04:00
setup.bat Core improvements batch1 (#3294) 2025-06-19 08:07:05 -04:00
setup.ps1 Improve setup. Add --headless option 2024-03-12 20:31:22 -04:00
setup.sh python3.11 support 2025-06-20 07:30:38 -04:00
uv.lock Update release 2025-06-23 08:35:07 -04:00

README.md

Kohya's GUI

GitHub stars GitHub forks License GitHub issues

A comprehensive GUI and CLI toolkit for training Stable Diffusion models, LoRAs, and other diffusion model variants.

Overview

This project provides a user-friendly Gradio-based interface for Kohya's Stable Diffusion training scripts, making it accessible for both beginners and advanced users to fine-tune diffusion models.

Key Features:

  • Easy-to-use GUI for configuring training parameters
  • Automatic CLI command generation for advanced users
  • Multiple training methods: LoRA, Dreambooth, Fine-tuning, SDXL, Flux.1, SD3
  • Cross-platform support: Windows, Linux, macOS
  • Flexible deployment: Local installation, Docker, or cloud-based

Table of Contents

Quick Start

Choose your preferred installation method:

Method Best For Time to Setup
Docker Quick start, consistency across systems 5-10 minutes
uv (Recommended) Latest features, faster dependency management 10-15 minutes
pip Traditional Python users, easier debugging 15-20 minutes
Cloud (Colab) No local GPU, testing, or limited resources 2-5 minutes

Fastest way to get started:

# Docker (if you have Docker + NVIDIA GPU)
git clone --recursive https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
docker compose up -d
# Access GUI at http://localhost:7860

# OR Local installation with uv (Linux/Windows)
git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
# See installation guides below for platform-specific steps

Installation Options

Local Installation

Install kohya_ss directly on your machine for maximum flexibility and performance.

System Requirements

  • GPU: NVIDIA GPU with CUDA support (8GB+ VRAM recommended)
  • RAM: 16GB minimum (32GB recommended for SDXL)
  • Storage: 20GB+ free space
  • Python: 3.10 or 3.11 (3.12 not yet supported)

Installation Methods

Platform Recommended Alternative Installation Guide
Windows uv pip uv_windows.md / pip_windows.md
Linux uv pip uv_linux.md / pip_linux.md
macOS pip uv pip_linux.md

uv vs pip - Which Should I Choose?

Use uv if:

  • You want the fastest installation and updates
  • You prefer automatic dependency isolation
  • You're setting up a new environment
  • You want minimal configuration hassle

Use pip if:

  • You're experienced with Python package management
  • You need fine-grained control over dependencies
  • You're integrating with existing Python tooling
  • You encounter issues with uv

Still unsure? Start with uv. If you encounter problems, fall back to pip.

Docker Installation

Best for: Consistent environment, easy updates, isolation from system Python.

Docker provides the fastest and most reliable way to run Kohya_ss with all dependencies pre-configured.

Prerequisites

  • Docker Desktop (Windows/Mac) or Docker Engine (Linux)
  • NVIDIA GPU with CUDA support
  • NVIDIA Container Toolkit (Linux) or WSL2 with GPU support (Windows)

Quick Start with Docker

# Clone repository with submodules
git clone --recursive https://github.com/bmaltais/kohya_ss.git
cd kohya_ss

# Start services
docker compose up -d

# Access the GUI
# Kohya GUI: http://localhost:7860
# TensorBoard: http://localhost:6006

Updating Docker Installation

# Stop containers
docker compose down

# Pull latest images and restart
docker compose up -d --pull always

Complete Docker documentation: docs/docker.md

Platform-specific setup:

Cloud-Based Solutions

No local GPU? Use these cloud alternatives:

Google Colab (Free)

Pros: Free GPU access, no installation required, browser-based Cons: Session limits, may disconnect, shared resources

Open In Colab

Special thanks to camenduru for maintaining the Colab version!

RunPod (Paid)

Pros: Dedicated GPUs, persistent storage, no session limits Cons: Costs money, requires account setup

Novita (Paid)

Pros: Integrated UI, easy setup, good for beginners Cons: Costs money, platform-specific

Configuration

Custom Path Defaults with config.toml

Streamline your workflow by setting default paths for models, datasets, and outputs.

Quick Setup

  1. Copy the example configuration:

    cp "config example.toml" config.toml
    
  2. Edit config.toml with your preferred paths:

    # Example configuration
    model_dir = "C:/ai/models/Stable-diffusion"
    lora_model_dir = "C:/ai/models/Lora"
    output_dir = "C:/ai/outputs"
    dataset_dir = "C:/ai/datasets"
    
  3. Use absolute paths or paths relative to the kohya_ss root directory

  4. Use forward slashes (/) even on Windows for compatibility

Configuration Structure

The config.toml file supports multiple sections for different training modes:

# General settings
model_dir = "/path/to/models"
lora_model_dir = "/path/to/lora"
vae_dir = "/path/to/vae"
output_dir = "/path/to/outputs"
logging_dir = "/path/to/logs"

# Dreambooth specific
db_model_dir = "/path/to/models"
db_reg_image_dir = "/path/to/regularization"

# LoRA specific
lc_model_dir = "/path/to/models"
lc_output_dir = "/path/to/outputs/lora"
lc_dataset_dir = "/path/to/datasets"

# See 'config example.toml' for complete list of options

Using Custom Config Path

Specify a different config file location:

# Windows
gui.bat --config D:/my_configs/kohya_settings.toml

# Linux/macOS
./gui.sh --config /home/user/my_configs/kohya_settings.toml

Full configuration reference: See config example.toml in the root directory

Training Features

LoRA Training

LoRA (Low-Rank Adaptation) allows efficient fine-tuning of Stable Diffusion models with minimal computational requirements.

Training a LoRA:

  1. Use the GUI's LoRA training tab
  2. Configure dataset and parameters
  3. Start training via train_network.py

Using trained LoRAs:

Documentation:

SDXL Training

Support for Stable Diffusion XL model training with optimized settings.

Resources:

Sample Image Generation

Generate sample images during training to monitor progress and quality.

Creating a Prompt File

Create a text file with prompts and generation parameters:

# prompt 1
masterpiece, best quality, (1girl), in white shirts, upper body, looking at viewer, simple background --n low quality, worst quality, bad anatomy, bad composition, poor, low effort --w 768 --h 768 --d 1 --l 7.5 --s 28

# prompt 2
masterpiece, best quality, 1boy, in business suit, standing at street, looking back --n (low quality, worst quality), bad anatomy, bad composition, poor, low effort --w 576 --h 832 --d 2 --l 5.5 --s 40

Available Options

  • --n: Negative prompt (text to avoid)
  • --w: Image width in pixels
  • --h: Image height in pixels
  • --d: Seed for reproducibility
  • --l: CFG scale (guidance strength)
  • --s: Number of sampling steps

Note: Prompt weighting with () and [] is supported.

Masked Loss

Enable masked loss to train only specific regions of images.

Activation: Add --masked_loss option in training configuration

How it works:

  • Uses ControlNet dataset format
  • RGB mask images where Red channel value determines weight
    • 255 (full weight) = train this area
    • 0 (no weight) = ignore this area
    • 128 (half weight) = partial training
  • Pixel values 0-255 map to loss weights 0.0-1.0

Documentation: LLLite Training Guide

Warning: This feature is experimental. Please report issues on GitHub.

Troubleshooting

Common Issues

Page File Limit (Windows)

Symptom: Error about page file size

Solution: Increase Windows virtual memory (page file) size:

  1. System Properties > Advanced > Performance Settings
  2. Virtual Memory > Change
  3. Set custom size (16GB+ recommended)

No module called 'tkinter'

Symptom: Import error for tkinter module

Solutions:

  • Windows: Reinstall Python 3.10 or 3.11 with "tcl/tk" option enabled
  • Linux: sudo apt-get install python3-tk
  • macOS: Reinstall Python from python.org (not Homebrew)

GPU Not Being Used / Low GPU Utilization

Symptoms: Training is slow, GPU usage at 0-10%

Solutions:

  1. Verify CUDA installation: nvidia-smi
  2. Check PyTorch GPU access:
    import torch
    print(torch.cuda.is_available())
    print(torch.cuda.get_device_name(0))
    
  3. Increase batch size
  4. Disable CPU offloading options
  5. See: Tesla V100 Troubleshooting

Out of Memory Errors

Solutions:

  • Reduce batch size
  • Enable gradient checkpointing
  • Use mixed precision training (fp16)
  • Lower resolution
  • Enable CPU offloading
  • Close other GPU applications

Docker-Specific Issues

See the comprehensive Docker Troubleshooting Guide for:

  • GPU not detected in container
  • Permission denied errors
  • Volume mount issues
  • Port conflicts

Getting Help

If you're stuck:

  1. Search existing issues: https://github.com/bmaltais/kohya_ss/issues
  2. Check documentation: See /docs directory
  3. Open a new issue with:
    • Operating system and version
    • Installation method (Docker/uv/pip)
    • Python version
    • Full error message and logs
    • Steps to reproduce

Advanced Usage

Accelerate Configuration for Multi-GPU

Use the Accelerate tab in the GUI to configure multi-GPU training:

  1. Open the "Accelerate launch" tab
  2. For single GPU: Uncheck "Multi-GPU", set GPU ID (e.g., "0" or "1")
  3. For multi-GPU: Check "Multi-GPU", configure device IDs

Running Multiple Instances (Linux)

Run separate GUI instances for different training jobs:

# Start first instance on port 7860
nohup ./gui.sh --listen 0.0.0.0 --server_port 7860 --headless > log_7860.log 2>&1 &

# Start second instance on port 7861
nohup ./gui.sh --listen 0.0.0.0 --server_port 7861 --headless > log_7861.log 2>&1 &

Monitoring: Use tmux or screen for terminal management

More details: GitHub Issue #2577

Command-Line Usage

The GUI generates CLI commands that can be run directly:

# Activate virtual environment first
source venv/bin/activate  # Linux/macOS
# or
venv\Scripts\activate.bat  # Windows

# Run training script directly
python sd-scripts/train_network.py \
  --pretrained_model_name_or_path=/path/to/model.safetensors \
  --train_data_dir=/path/to/dataset \
  --output_dir=/path/to/output \
  # ... additional parameters

Using Different Python Versions

Kohya_ss supports Python 3.10 and 3.11:

# Create environment with specific version
uv venv --python 3.11
# or
python3.11 -m venv venv

Interesting Forks

Community-maintained variants with additional features:

Contributing

Contributions are welcome! Help improve Kohya_ss by:

Reporting Issues:

  • Use GitHub Issues
  • Include detailed reproduction steps
  • Provide system information and logs

Submitting Code:

  • Fork the repository
  • Create a feature branch
  • Follow existing code style
  • Test thoroughly before submitting PR
  • Document new features

Security Issues:

License

This project is licensed under the Apache License 2.0.

See LICENSE.md for complete terms.

Change History

v25.2.1 (Current)

  • Latest stable release
  • Python 3.11 support
  • Updated dependencies

v25.0.3

  • Upgraded Gradio, diffusers, and huggingface-hub to fix ASGI issues
  • New simplified setup scripts:
    • gui-uv.bat (Windows) and gui-uv.sh (Linux)
    • No need to run separate setup scripts anymore

v25.0.2

  • Forced Gradio upgrade to 5.14.0+ for critical updates

v25.0.1

  • Fixed requirements versioning issues affecting Hugging Face downloads

v25.0.0

  • Major update: Added support for Flux.1 and SD3
  • Aligned GUI with latest sd-scripts features
  • Breaking changes: Previous workflows may need adjustment

Note: For pre-Flux.1/SD3 version, checkout tag v24.1.7:

git checkout v24.1.7

Flux.1 and SD3 Parameters:

Older Versions

For complete version history, see GitHub Releases.


Quick Reference

Default Ports

  • Kohya GUI: 7860
  • TensorBoard: 6006

File Locations

  • Config: config.toml (root directory)
  • Training Scripts: sd-scripts/ (submodule)
  • Documentation: docs/
  • Examples: examples/

Supported Models

  • Stable Diffusion 1.x, 2.x
  • Stable Diffusion XL (SDXL)
  • Stable Diffusion 3 (SD3)
  • Flux.1
  • Custom fine-tuned models

Training Methods

  • LoRA (Low-Rank Adaptation)
  • Dreambooth
  • Fine-tuning
  • Textual Inversion
  • LLLite

Need help? Check the documentation or open an issue!