Add setup script for ubuntu users

This commit is contained in:
devdn 2023-03-03 18:17:29 -05:00
parent 4812e441a0
commit 38bdcea3c5
3 changed files with 54 additions and 0 deletions

View File

@ -38,6 +38,18 @@ PowerShellを使う場合、venvを使えるようにするためには以下の
- 「Set-ExecutionPolicy Unrestricted」と入力し、Yと答えます。
- 管理者のPowerShellを閉じます。
## Ubuntu環境でのインストール
```
git clone https://github.com/kohya-ss/sd-scripts.git
cd sd-scripts
bash ubuntu_setup.sh
```
をコマンドプロンプトで実行し、tkをインストールし、accelerateの質問をWindowsと同じように答えます。
`./gui.sh`でGUIを実行します。
## Windows環境でのインストール
以下の例ではPyTorchは1.12.1CUDA 11.6版をインストールします。CUDA 11.3版やPyTorch 1.13を使う場合は適宜書き換えください。

View File

@ -41,6 +41,19 @@ If you run on Linux and would like to use the GUI, there is now a port of it as
## Installation
### Ubuntu
In the terminal, run
```
git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
bash ubuntu_setup.sh
```
then configure accelerate with the same answers as in the Windows instructions when prompted.
### Windows
Give unrestricted script access to powershell so venv can work:
- Run PowerShell as an administrator

29
ubuntu_setup.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
echo installing tk
sudo apt install python3-tk
python3 -m venv venv
source venv/bin/activate
pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 --extra-index-url https://download.pytorch.org/whl/cu116
pip install --use-pep517 --upgrade -r requirements.txt
pip install -U -I --no-deps https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/linux/xformers-0.0.14.dev0-cp310-cp310-linux_x86_64.whl
accelerate config
rm *.bat
rm *.ps1
set +H
echo "#!/bin/bash" > gui.sh
echo "source venv/bin/activate" >> gui.sh
echo "python kohya_gui.py $@" >> gui.sh
chmod +x gui.sh
sources=$(find $(ls | grep -v venv) | egrep "\.py$")
for source in $sources
do
#fix accelerate commands
sed -i -r 's/(accelerate launch .*?)"(.+?\.py)"/\1\2/g' $source
sed -i -r 's/subprocess.run\(run_cmd\)/subprocess.run(run_cmd, shell=True)/g' $source
done
echo -e "setup finished! run \e[0;92m./gui.sh\e[0m to start"