Commit 088a39d8 authored by 孙傲's avatar 孙傲

完善 AutoDL 部署脚本

parent 746367b7
记录 `Stable Diffusion` 本地环境搭建过程,以及 `Stable Diffusion` 的使用方法。
以下步骤均为`Windows 64位`环境下的操作,推荐使用`Windows 11`
# 一、环境安装
多种环境配置,任选其一即可!
## 1. AutoDL
以下步骤为`基础镜像 > Miniconda / conda3 / 3.10(ubuntu22.04) / 11.8` + 显卡`RTX 3090 * 1卡`环境下操作
ssh 链接上服务器依次执行如下命令:
一、环境安装
```shell
# 检查GPU,查询CUDA、CUDNN版本
nvidia-smi
1. 下载依赖
ldconfig -p | grep cuda
ldconfig -p | grep cudnn
# 加速 github、huggingface
source /etc/network_turbo
# 下载安装包
wget https://git.devops.yitong.com/yitong-public/awesome-stable-diffusion/-/archive/master/awesome-stable-diffusion-master.zip
# 解压, 如果没有解压工具,先执行: sudo apt install unzip
unzip awesome-stable-diffusion-master.zip
# 重命名
mv awesome-stable-diffusion-master stable-diffusion
# 目录权限设置
chmod -R 777 stable-diffusion
# 配置 Stable Diffusion web UI ,耐心等待配置完成
cd ~/stable-diffusion/stable-diffusion-webui/
./webui-user.sh
./webui.sh
# 如果看到日志 Running on local URL: http://127.0.0.1:6006/ 说明配置成功
# 退出按 Ctrl + C
# 基础镜像安装python依赖默认是阿里云镜像网站,如果安装下载速度慢,可以退出后修改为其他镜像网站,修改后在记录执行配置相关命令
# 清华
# pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 百度
# pip config set global.index-url https://mirror.baidu.com/pypi/simple
# 阿里云
# pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
# 将 Stable Diffusion web UI 常驻在后台运行
# 首次使用
screen -S sd
# 非首次使用
# screen -r sd
cd ~/stable-diffusion/stable-diffusion-webui/
./webui-user.sh
./webui.sh
# 按 Ctrl + A + D 退出(退出不会影响程序运行)
# 配置 LoRA 训练环境,耐心等待配置完成
cd ~/stable-diffusion/lora-scripts/
./install.bash
# 安装完成后会提示 `Install completed`
```
安装过程中的一些辅助命令:
```shell
# 计算当前目录的磁盘空间占用情况
du -h --max-depth=1 ./ | sort -hr
# 系统盘空间有限,将比较大的文件软连接到其他位置
ln -s /root/autodl-tmp/stable-diffusion-webui/models/Stable-diffusion /root/stable-diffusion/stable-diffusion-webui/models/Stable-diffusion
```
推荐使用 Visual Studio Code 插件 `Remote - SSH` 连接服务器,方便文件上传下载、编辑、查看等操作。
## 2.Windows
以下步骤为`Windows 11 64位`环境下的操作
### 2.1. 下载依赖
点击 [此处](https://git.devops.yitong.com/yitong-public/awesome-stable-diffusion/-/archive/master/awesome-stable-diffusion-master.zip) 下载依赖包,解压到任意目录。
例如解压到`D盘`根目录,对应解码目录为: `D:\awesome-stable-diffusion-master\`,目录结构如下:
......@@ -23,17 +93,17 @@ d----- 2023/7/10 14:48 tools
------ 2023/7/10 14:48 179 README.md
```
2. 安装 `git`
### 2.2. 安装 `git`
双击 `D:\awesome-stable-diffusion-master\tools\Git-2.41.0.2-64-bit.exe` 安装 `git`,安装过程中一路下一步即可。
3. 安装 `Python`
### 2.3. 安装 `Python`
双击 `D:\awesome-stable-diffusion-master\tools\python-3.10.11-amd64.exe` 安装 `Python`
**注意:安装过程中勾选 `Add python.exe to PATH`**
安装界面的第一步最下面就有`Add python.exe to PATH`选项,勾选后直接选第一个 `Install Now`,一路下一步即可。
4. 配置 `Stable Diffusion web UI`
### 2.4. 配置 `Stable Diffusion web UI`
双击 `D:\awesome-stable-diffusion-master\stable-diffusion-webui\webui-user.bat` 程序自动安装依赖,安装过程中过下载较大文件,**耐心等待**。
5. 配置 `LoRA` 训练环境
### 2.5. 配置 `LoRA` 训练环境
右键点击 `D:\awesome-stable-diffusion-master\lora-scripts\install-cn.ps1`,选择 `使用 PowerShell 运行`**耐心等待**
......@@ -32,10 +32,7 @@ export COMMANDLINE_ARGS="--xformers --port 6006"
# Fixed git repos
#export K_DIFFUSION_PACKAGE=""
export GFPGAN_PACKAGE="https://public.yitong.com/mirrors/github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip"
export CLIP_PACKAGE="https://public.yitong.com/mirrors/github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip"
export OPENCLIP_PACKAGE="https://public.yitong.com/mirrors/github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip"
# export GFPGAN_PACKAGE=""
# Fixed git commits
#export STABLE_DIFFUSION_COMMIT_HASH=""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment