作为一个机器学习研究人员或开发者,环境搭建对于进行模型训练是非常重要的一步。本文将以Stable Diffusion为例,介绍如何在Windows操作系统下搭建模型训练环境,并提供Linux上的GUI部署参考。
环境搭建首先,我们以GitHub上的bmaltais/kohya_ss项目为例,该项目提供了在Windows操作系统下的GUI训练面板。在进行环境搭建之前,请确保设备已经安装了Python 3.10.6和git环境。
Set-ExecutionPolicy Unrestricted
在提示时回答”A”,然后可以关闭该窗口。
git clone https://github.com/bmaltais/kohya_ss.git
cd kohya_ss
python -m venv venv
.\venv\Scripts\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/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl
cp .\bitsandbytes_windows\*.dll .\venv\Lib\site-packages\bitsandbytes\
通过以上步骤,您已经成功搭建了在Windows操作系统下使用GUI进行模型训练的环境。
如果您需要在Linux上部署,并且需要GUI界面,我们可以参考GitHub上的P2Enjoy/kohya_ss-docker项目。该项目是将kohya_ss训练Web UI转换为适用于Linux的镜像。
根据这个项目的说明进行部署即可。