Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaltais authored Mar 17, 2024
2 parents 2a5fa82 + 6386a72 commit ade4c22
Show file tree
Hide file tree
Showing 44 changed files with 1,855 additions and 828 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ requirements_tmp_for_setup.txt
*.npz
presets/*/user_presets/*
inputs
outputs
outputs
dataset/**
!dataset/**/
!dataset/**/.gitkeep
# models
# data
2 changes: 1 addition & 1 deletion .release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v23.0.11
v23.0.12
49 changes: 25 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,8 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \

FROM python:3.10-slim as final

ARG UID
ARG VERSION
ARG RELEASE

LABEL name="bmaltais/kohya_ss" \
vendor="bmaltais" \
maintainer="bmaltais" \
# Dockerfile source repository
url="https://github.com/bmaltais/kohya_ss" \
version=${VERSION} \
# This should be a number, incremented with each change
release=${RELEASE} \
io.k8s.display-name="kohya_ss" \
summary="Kohya's GUI: This repository provides a Gradio GUI for Kohya's Stable Diffusion trainers(https://github.com/kohya-ss/sd-scripts)." \
description="The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model. This is the docker image for Kohya's GUI. For more information about this tool, please visit the following website: https://github.com/bmaltais/kohya_ss."
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

# Install runtime dependencies
RUN apt-get update && \
Expand All @@ -81,6 +68,7 @@ RUN ln -s /usr/lib/x86_64-linux-gnu/libnvinfer.so /usr/lib/x86_64-linux-gnu/libn
ln -s /usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so /usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so.7

# Create user
ARG UID
RUN groupadd -g $UID $UID && \
useradd -l -u $UID -g $UID -m -s /bin/sh -N $UID

Expand All @@ -89,21 +77,20 @@ RUN install -d -m 775 -o $UID -g 0 /dataset && \
install -d -m 775 -o $UID -g 0 /licenses && \
install -d -m 775 -o $UID -g 0 /app

# Copy dist and support arbitrary user ids (OpenShift best practice)
COPY --chown=$UID:0 --chmod=775 \
--from=build /root/.local /home/$UID/.local

WORKDIR /app
COPY --chown=$UID:0 --chmod=775 . .

# Copy licenses (OpenShift Policy)
COPY --chmod=775 LICENSE.md /licenses/LICENSE.md
COPY --link --chmod=775 LICENSE.md /licenses/LICENSE.md

# Copy dependencies and code (and support arbitrary uid for OpenShift best practice)
COPY --link --chown=$UID:0 --chmod=775 --from=build /root/.local /home/$UID/.local
COPY --link --chown=$UID:0 --chmod=775 . /app

ENV PATH="/home/$UID/.local/bin:$PATH"
ENV PYTHONPATH="${PYTHONPATH}:/home/$UID/.local/lib/python3.10/site-packages"
ENV LD_PRELOAD=libtcmalloc.so
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

WORKDIR /app

VOLUME [ "/dataset" ]

# 7860: Kohya GUI
Expand All @@ -116,4 +103,18 @@ STOPSIGNAL SIGINT

# Use dumb-init as PID 1 to handle signals properly
ENTRYPOINT ["dumb-init", "--"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860"]
CMD ["python3", "kohya_gui.py", "--listen", "0.0.0.0", "--server_port", "7860"]

ARG VERSION
ARG RELEASE
LABEL name="bmaltais/kohya_ss" \
vendor="bmaltais" \
maintainer="bmaltais" \
# Dockerfile source repository
url="https://github.com/bmaltais/kohya_ss" \
version=${VERSION} \
# This should be a number, incremented with each change
release=${RELEASE} \
io.k8s.display-name="kohya_ss" \
summary="Kohya's GUI: This repository provides a Gradio GUI for Kohya's Stable Diffusion trainers(https://github.com/kohya-ss/sd-scripts)." \
description="The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model. This is the docker image for Kohya's GUI. For more information about this tool, please visit the following website: https://github.com/bmaltais/kohya_ss."
80 changes: 43 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kohya's GUI

This repository mostly provides a Gradio GUI for [Kohya's Stable Diffusion trainers](https://github.com/kohya-ss/sd-scripts)... but support for Linux OS is also provided through community contributions. Macos is not great at the moment... but might work if the wind blow in the right direction...
This repository primarily provides a Gradio GUI for [Kohya's Stable Diffusion trainers](https://github.com/kohya-ss/sd-scripts). However, support for Linux OS is also offered through community contributions. macOS support is not optimal at the moment but might work if the conditions are favorable.

The GUI allows you to set the training parameters and generate and run the required CLI commands to train the model.

Expand Down Expand Up @@ -37,6 +37,7 @@ The GUI allows you to set the training parameters and generate and run the requi
- [No module called tkinter](#no-module-called-tkinter)
- [SDXL training](#sdxl-training)
- [Change History](#change-history)
- [2024/03/16 (v23.0.12)](#20240316-v23012)
- [2024/03/13 (v23.0.11)](#20240313-v23011)
- [2024/03/13 (v23.0.9)](#20240313-v2309)
- [2024/03/12 (v23.0.8)](#20240312-v2308)
Expand Down Expand Up @@ -70,11 +71,11 @@ To install the necessary dependencies on a Windows system, follow these steps:
1. Install [Python 3.10.11](https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe).
- During the installation process, ensure that you select the option to add Python to the 'PATH' environment variable.

2. Install [CUDA 11.8 toolkit](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Windows&target_arch=x86_64)
2. Install [CUDA 11.8 toolkit](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Windows&target_arch=x86_64).

2. Install [Git](https://git-scm.com/download/win).
3. Install [Git](https://git-scm.com/download/win).

3. Install the [Visual Studio 2015, 2017, 2019, and 2022 redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe).
4. Install the [Visual Studio 2015, 2017, 2019, and 2022 redistributable](https://aka.ms/vs/17/release/vc_redist.x64.exe).

#### Setup Windows

Expand All @@ -100,13 +101,13 @@ To set up the project, follow these steps:
.\setup.bat
```

During the accelerate config step use the default values as proposed during the configuration unless you know your hardware demand otherwise. The amount of VRAM on your GPU does not have an impact on the values used.
During the accelerate config step, use the default values as proposed during the configuration unless you know your hardware demands otherwise. The amount of VRAM on your GPU does not impact the values used.

#### Optional: CUDNN 8.9.6.50

The following steps are optional but will improve the learning speed for owners of NVIDIA 30X0/40X0 GPUs. These steps enable larger training batch sizes and faster training speeds.

1. Run .\setup.bat and select `2. (Optional) Install cudnn files (if you want to use latest supported cudnn version)`
1. Run `.\setup.bat` and select `2. (Optional) Install cudnn files (if you want to use the latest supported cudnn version)`.
### Linux and macOS
Expand All @@ -120,7 +121,7 @@ To install the necessary dependencies on a Linux system, ensure that you fulfill
apt install python3.10-venv
```
- Install the CUDA 11.8 Tolkit by following the instructions provided in [this link](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64).
- Install the CUDA 11.8 Toolkit by following the instructions provided in [this link](https://developer.nvidia.com/cuda-11-8-0-download-archive?target_os=Linux&target_arch=x86_64).
- Make sure you have Python version 3.10.9 or higher (but lower than 3.11.0) installed on your system.
Expand Down Expand Up @@ -188,13 +189,13 @@ To install the necessary components for Runpod and run kohya_ss, follow these st
./setup-runpod.sh
```
5. Run the gui with:
5. Run the GUI with:
```shell
./gui.sh --share --headless
```
or with this if you expose 7860 directly via the runpod configuration
or with this if you expose 7860 directly via the runpod configuration:
```shell
./gui.sh --listen=0.0.0.0 --headless
Expand All @@ -204,13 +205,13 @@ To install the necessary components for Runpod and run kohya_ss, follow these st
#### Pre-built Runpod template
To run from a pre-built Runpod template you can:
To run from a pre-built Runpod template, you can:
1. Open the Runpod template by clicking on <https://runpod.io/gsc?template=ya6013lj5a&ref=w18gds2n>
1. Open the Runpod template by clicking on <https://runpod.io/gsc?template=ya6013lj5a&ref=w18gds2n>.
2. Deploy the template on the desired host
2. Deploy the template on the desired host.
3. Once deployed connect to the Runpod on HTTP 3010 to connect to kohya_ss GUI. You can also connect to auto1111 on HTTP 3000.
3. Once deployed, connect to the Runpod on HTTP 3010 to access the kohya_ss GUI. You can also connect to auto1111 on HTTP 3000.
### Docker
Expand All @@ -235,13 +236,13 @@ If you prefer to use Docker, follow the instructions below:
- All training data must be placed in the `dataset` subdirectory, as the Docker container cannot access files from other directories.
- The file picker feature is not functional. You need to manually set the folder path and config file path.
- Dialogs may not work as expected, and it is recommended to use unique file names to avoid conflicts.
- This dockerfile has been designed to be easily disposable. You can discard the container at any time and docker build it with a new version of the code. To update the system, run update scripts outside of Docker and rebuild using `docker compose down && docker compose up -d --build`.
- This Dockerfile has been designed to be easily disposable. You can discard the container at any time and docker build it with a new version of the code. To update the system, run update scripts outside of Docker and rebuild using `docker compose down && docker compose up -d --build`.
If you are running Linux, an alternative Docker container port with fewer limitations is available [here](https://github.com/P2Enjoy/kohya_ss-docker).
#### ashleykleynhans runpod docker builds
You may want to use the following Dockerfile repos to build the images:
You may want to use the following Dockerfile repositories to build the images:
- Standalone Kohya_ss template: <https://github.com/ashleykleynhans/kohya-docker>
- Auto1111 + Kohya_ss GUI template: <https://github.com/ashleykleynhans/stable-diffusion-docker>
Expand Down Expand Up @@ -270,9 +271,7 @@ If a new release becomes available, you can upgrade your repository by running t
To upgrade your installation on Linux or macOS, follow these steps:
1. Open a terminal and navigate to the root
directory of the project.
1. Open a terminal and navigate to the root directory of the project.
2. Pull the latest changes from the repository:
Expand Down Expand Up @@ -349,7 +348,7 @@ Lines beginning with `#` are comments. You can specify options for the generated
- `--l`: Specifies the CFG scale of the generated image.
- `--s`: Specifies the number of steps in the generation.
The prompt weighting such as `( )` and `[ ]` are working.
The prompt weighting such as `( )` and `[ ]` is working.
## Troubleshooting
Expand All @@ -369,54 +368,61 @@ The documentation in this section will be moved to a separate document later.
## Change History
### 2024/03/16 (v23.0.12)
- Add support for `wandb_run_name`, `log_tracker_name` and `log_tracker_config` parameters under the advanced section.
- Update sd-scripts to v0.8.5
- Improve code
- Add support for custom path defaults. Simply copy the `config example.toml` file found in the root of the repo to `config.toml` and edit the different values to your taste.
### 2024/03/13 (v23.0.11)
- Increase icon size
- More setup fixes
- Increase icon size.
- More setup fixes.
### 2024/03/13 (v23.0.9)
- Reworked how setup can be run to improve Stability Matrix support
- Add support for huggingface based vea path
- Reworked how setup can be run to improve Stability Matrix support.
- Added support for huggingface-based vea path.
### 2024/03/12 (v23.0.8)
- Add the ability to create output and logs folder if it does not exist
### 2024/03/12 (v23.0.7)
- Fix minor issues related to functions and file path
- Fixed minor issues related to functions and file paths.
### 2024/03/11 (v23.0.6)
- Fix issue with PYTHON path that have "spaces" in them
- Fixed an issue with PYTHON paths that have "spaces" in them.
### 2024/03/11 (v23.0.5)
- Update python module verification
- Remove cudnn module installation in windows
- Updated python module verification.
- Removed cudnn module installation in Windows.
### 2024/03/10 (v23.0.4)
- Update bitsandbytes to 0.43.0
- Add packaging to runpod setup
- Updated bitsandbytes to 0.43.0.
- Added packaging to runpod setup.
### 2024/03/10 (v23.0.3)
- Fix bug with setup
- Enforce proper python version before running the GUI to prevent issues with execution of the GUI.
- Fixed a bug with setup.
- Enforced proper python version before running the GUI to prevent issues with execution of the GUI.
### 2024/03/10 (v23.0.2)
- Improve validation of path provided by users before running training
- Improved validation of the path provided by users before running training.
### 2024/03/09 (v23.0.1)
- Update bitsandbytes module to 0.43.0 as it provide native windows support
- Minor fixes to code
- Updated bitsandbytes module to 0.43.0 as it provides native Windows support.
- Minor fixes to the code.
### 2024/03/02 (v23.0.0)
- Use sd-scripts release [0.8.4](https://github.com/kohya-ss/sd-scripts/releases/tag/v0.8.4) post commit [fccbee27277d65a8dcbdeeb81787ed4116b92e0b](https://github.com/kohya-ss/sd-scripts/commit/fccbee27277d65a8dcbdeeb81787ed4116b92e0b)
- Major code refactoring thanks to @wkpark , This will make updating sd-script cleaner by keeping sd-scripts files separate from the GUI files. This will also make configuration more streamlined with fewer tabs and more accordion elements. Hope you like the new style.
- This new release is implementing a significant structure change, moving all of the sd-scripts written by kohya under a folder called sd-scripts in the root of this project. This folder is a submodule that will be populated during setup or gui execution.
- Used sd-scripts release [0.8.4](https://github.com/kohya-ss/sd-scripts/releases/tag/v0.8.4) post commit [fccbee27277d65a8dcbdeeb81787ed4116b92e0b](https://github.com/kohya-ss/sd-scripts/commit/fccbee27277d65a8dcbdeeb81787ed4116b92e0b).
- Major code refactoring thanks to @wkpark. This will make updating sd-scripts cleaner by keeping sd-scripts files separate from the GUI files. This will also make configuration more streamlined with fewer tabs and more accordion elements. Hope you like the new style.
- This new release is implementing a significant structure change, moving all of the sd-scripts written by kohya under a folder called sd-scripts in the root of this project. This folder is a submodule that will be populated during setup or GUI execution.
13 changes: 13 additions & 0 deletions config example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copy this file and name it config.toml
# Edit the values to suit your needs

# Default folders location
models_dir = "./models" # Pretrained model name or path
train_data_dir = "./data" # Image folder (containing training images subfolders) / Image folder (containing training images)
output_dir = "./outputs" # Output directory for trained model
reg_data_dir = "./data/reg" # Regularisation directory
logging_dir = "./logs" # Logging directory
config_dir = "./presets" # Load/Save Config file

# Example custom folder location
# models_dir = "e:/models" # Pretrained model name or path
File renamed without changes.
Empty file added dataset/logs/.gitkeep
Empty file.
Empty file added dataset/outputs/.gitkeep
Empty file.
Empty file added dataset/regularization/.gitkeep
Empty file.
12 changes: 7 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: "3.8"

services:
kohya-ss-gui:
container_name: kohya-ss-gui
Expand All @@ -11,22 +12,23 @@ services:
ports:
- 7860:7860
- 6006:6006
tty: true
ipc: host
environment:
CLI_ARGS: ""
SAFETENSORS_FAST_GPU: 1
DISPLAY: $DISPLAY
tmpfs:
- /tmp
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix
- ./dataset:/dataset
- ./dataset/images:/app/data
- ./dataset/logs:/app/logs
- ./dataset/outputs:/app/outputs
- ./dataset/regularization:/app/regularization
- ./.cache/config:/app/config
- ./.cache/user:/home/1000/.cache
- ./.cache/triton:/home/1000/.triton
- ./.cache/nv:/home/1000/.nv
- ./.cache/keras:/home/1000/.keras
- ./.cache/config:/home/1000/.config
- ./.cache/config:/home/1000/.config # For backward compatibility
deploy:
resources:
reservations:
Expand Down
Loading

0 comments on commit ade4c22

Please sign in to comment.