Install Kohya_SS on Windows Using WSL 2 Ubuntu

How to install Kohya_SS to Ubuntu WSL 2 under Windows 11.

1) Prepare

  1. Check CPU virtualization on Windows > Task Manager > Perfomance > CPU > Virtualization: Enabled or Disabled.
  2. If Disabled - Access the UEFI (or BIOS). The way the UEFI (or BIOS) appears depends on your PC manufacturer. Learn how here.
  3. Make sure you are using a recent version of Windows 10/11 (No earlier than Windows 10, Version 1903, Build 18362). If needed, update to the latest version.

2) Install WSL and Ubuntu

  1. Open Terminal and use the command:
    wsl --install
  2. Open the Microsoft Store, find and install "Ubuntu". The one which doesn't show a version number in the name is the latest.
  3. Open Ubuntu from your Start Menu.
  4. Create a user profile when prompted (e.g., Username: User, Password: User).

3) Install Kohya_SS on WSL 2 Ubuntu

Prepare Environment

sudo apt update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev -y
sudo apt update -y && sudo apt install -y python3-tk
sudo apt install python3.10-tk
sudo apt install git -y

NVIDIA CUDA Toolkit

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-9
export PATH=/usr/local/cuda-12.9/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64\${LD_LIBRARY_PATH:+:\${LD_LIBRARY_PATH}}

NVIDIA cuDNN

wget https://developer.download.nvidia.com/compute/cudnn/9.10.2/local_installers/cudnn-local-repo-ubuntu2404-9.10.2_1.0-1_amd64.deb
sudo dpkg -i cudnn-local-repo-ubuntu2404-9.10.2_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-ubuntu2404-9.10.2/cudnn-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cudnn
sudo apt-get -y install cudnn-cuda-12

Reboot WSL

After installing drivers, it's a good idea to restart the WSL instance. Open a Windows Terminal and run wsl --shutdown, then re-open your Ubuntu terminal.

sudo reboot

Install Kohya_SS

cd ~
git clone --recursive https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
./setup.sh
git checkout sd3-sd3.5-flux

Configure Accelerate

Run the configuration script:

source venv/bin/activate
accelerate config

Answer the prompts as follows:

  • This machine
  • No distributed training
  • NO
  • NO
  • NO
  • all
  • yes

If you have an RTX 30/40/50 series video card, choose bf16. Otherwise, choose fp16.

4) Update PyTorch for Kohya_SS

Note: xFormers might not work with this version. Only SDPA is supported.

Open and replace the content of requirements_linux.txt with the following line:

torch==2.7.1+cu128

Run Kohya_SS on WSL 2 Ubuntu

cd kohya_ss
source venv/bin/activate
./gui.sh

Notes

To find the Kohya_ss folder from Windows Explorer, navigate to \\wsl.localhost\Ubuntu\home\user. You can move your models and datasets there.

Additional commands for Windows Terminal

Shutdown WSL:

wsl --shutdown

Uninstall or reset your Ubuntu installation:

wsl --unregister Ubuntu