Skip to content

Instantly share code, notes, and snippets.

@jstayco
Last active September 12, 2023 19:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jstayco/9f5733f05b9dc29de95c4056a023d645 to your computer and use it in GitHub Desktop.
Save jstayco/9f5733f05b9dc29de95c4056a023d645 to your computer and use it in GitHub Desktop.
Setup script for Kohya SS on macOS

MacOS (Apple Silicon)

In the terminal, run

git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
# Patch these files into top level/root project folder
# Then run the next command
bash ./macos.sh

During the accelerate config screen after running the script answer "This machine", "None", "No" for the remaining questions.

#!/bin/bash
# The initial setup script to prep the environment on macOS
# xformers has been omitted as that is for Nvidia GPUs only
if ! command -v brew >/dev/null; then
echo "Please install homebrew first. This is a requirement for the remaining setup."
echo "You can find that here: https://brew.sh"
exit 1
fi
# Install base python packages
echo "Installing Python 3.10 if not found."
brew ls --versions python@3.10 >/dev/null || brew install python@3.10
echo "Installing Python-TK 3.10 if not found."
brew ls --versions python-tk@3.10 >/dev/null || brew install python-tk@3.10
if command -v python3.10 >/dev/null; then
python3.10 -m venv venv
source venv/bin/activate
# DEBUG ONLY
#pip install pydevd-pycharm~=223.8836.43
# Tensorflow installation
if wget https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl /tmp; then
python -m pip install tensorflow==0.1a3 -f https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha3/tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
rm -f /tmp/tensorflow_macos-0.1a3-cp38-cp38-macosx_11_0_arm64.whl
fi
pip install torch==2.0.0 torchvision==0.15.1 -f https://download.pytorch.org/whl/cpu/torch_stable.html
python -m pip install --use-pep517 --upgrade -r requirements.txt
accelerate config
echo -e "Setup finished! Run ./gui.sh to start."
else
echo "Python not found. Please ensure you install Python."
echo "The brew command for Python 3.10 is: brew install python@3.10"
exit 1
fi
accelerate==0.15.0
albumentations==1.3.0
altair==4.2.2
bitsandbytes==0.35.0
dadaptation==1.5
diffusers[torch]==0.10.2
easygui==0.98.3
einops==0.6.0
ftfy==6.1.1
gradio==3.19.1; sys_platform != 'darwin'
gradio==3.23.0; sys_platform == 'darwin'
lion-pytorch==0.0.6
opencv-python==4.7.0.68
pytorch-lightning==1.9.0
safetensors==0.2.6
tensorboard==2.10.1
tk==0.1.0
toml==0.10.2
transformers==4.26.0
voluptuous==0.13.1
# for BLIP captioning
fairscale==0.4.13
requests==2.28.2
timm==0.6.12
# tensorflow<2.11
huggingface-hub==0.12.0; sys_platform != 'darwin'
huggingface-hub==0.13.0; sys_platform == 'darwin'
tensorflow==2.10.1; sys_platform != 'darwin'
# For locon support
lycoris_lora==0.1.2
# for kohya_ss library
.
@tuetano
Copy link

tuetano commented May 15, 2023

Thanks for the help on this, question I have:
1. how do I patch the files.
2. where do I run this command that doesn't work:
kohya_ss % bash ./macos.sh
bash: ./macos.sh: No such file or directory

@jstayco
Copy link
Author

jstayco commented May 15, 2023

Apologies, this is now out dated. There is a setup.sh that you should run in the main repo that is better than this script. https://github.com/bmaltais/kohya_ss

@retret66
Copy link

the setup.sh works but clicking on folders in folder tab doesnt do anything, seems useless for Mac

@Xenetixt
Copy link

it's no big deal. you can copy/paste the path of your folders in it

@retret66
Copy link

retret66 commented Sep 8, 2023

setup still doesnt work using gui, I created my own branch from kohya_ss which works with MPS , however I just run the script not the gui but it works with GPU acceleration. and followed this after: https://hackmd.io/@cy2023/r1_sKqlg3
https://github.com/retret66/sd-scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment