Merge pull request #626 from aki66938/sd-webui-comfy

sd webui comfy
This commit is contained in:
okxlin 2023-12-19 00:59:35 +08:00 committed by GitHub
commit d334e72701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,45 @@
## 项目介绍
stable-deffusion是基于pytorch的目标检测模型
当前版本镜像支持GPUCPU模式需要修改yaml参数未测试。
GPU最小8G起4G显存下未测试
安装过程比较漫长,取决于初始模型下载速度,需要耐心等待
安装面板支持apt、pip指令。详细可参考yml文件当前版本默认安装即可由于比较消耗资源限定镜像仅部署1个
本镜像仅做移植所有功能基于原作者参考https://github.com/thirdscam/SD-WebUI-Docker
webui有两个可以选择都在应用商店里a1111版和comfy
安装前确保docker默认支持gpu配置在/etc/docker/daemon.json上改像这样
```
{
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
},
"default-runtime": "nvidia"
}
```
## 关于缺少依赖的报错
安装镜像过程会自动安装当前版本所需依赖
为适应未来版本变化添加了apt和pip指令当前版本不填即可。
当然如果宿主机未安装nvidia-docker-runtime、nvidia-docker2、nvidia-container-toolkit等nvidia容器运行的依赖可以使用该功能只需在APT参数上写包名即可多个包加空格。
## 关于GPU
当前仅设置单GPUnvdia-smi可以查看gpu的ID默认0单显卡默认即可
多显卡可以根据id选择
如果需要使用所有显卡需要更改yaml文件将id设置为all
## 其他
stable-deffusion相关教程https://www.bilibili.com/video/BV1As4y127HW/?spm_id_from=333.337.search-card.all.click&vd_source=101386edb3f81944f8492e12ee8cb5b6
## api接口
http://localhost:7860/docs/
## 模型下载站
https://civitai.com/

View File

@ -0,0 +1,13 @@
additionalProperties: #固定参数
key: sd-webui-comfy #应用的 key ,仅限英文,用于在 Linux 创建文件夹
name: sd-webui-comfy #应用名称
tags:
- Local #应用标签,可以有多个,请参照下方的标签列表
shortDescZh: comfy版sd-web #应用中文描述不要超过30个字
shortDescEn: stable-diffusion-webui-comfy #应用英文描述
type: Local #应用类型,区别于应用分类,只能有一个,请参照下方的类型列表
crossVersionUpdate: true #是否可以跨大版本升级
limit: 0 #应用安装数量限制0 代表无限制
website: https://github.com/thirdscam/SD-WebUI-Docker #官网地址
github: https://github.com/thirdscam/SD-WebUI-Docker #github 地址
document: https://github.com/thirdscam/SD-WebUI-Docker #文档地址

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,32 @@
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PIP_PREFER_BINARY=1
ENV ROOT=/apt
RUN mkdir ${ROOT}
WORKDIR ${ROOT}
# Install Essential Packages (APT)
RUN apt-get update && apt-get install -y git python3 python3-pip && apt-get clean
# Get Comfy
RUN git clone https://github.com/comfyanonymous/ComfyUI.git .
# Install Essential Packages (PIP)
RUN --mount=type=cache,target=/root/.cache/pip \
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 && \
pip install -r requirements.txt && \
pip install --pre xformers && \
pip install triton
# Setting up
COPY entrypoint.sh /docker/entrypoint.sh
RUN chmod +x /docker/entrypoint.sh
ENTRYPOINT ["/docker/entrypoint.sh"]
ENV PYTHONPATH="${PYTHONPATH}:${PWD}"
CMD test -z "${APT_ARGS}" || apt-get -y install ${APT_ARGS} \
&& test -z "${PIP_ARGS}" || pip install ${PIP_ARGS} \
&& python3 -u main.py ${CLI_ARGS}

View File

@ -0,0 +1,46 @@
#!/bin/bash
set -Eeuo pipefail
declare -A MOUNTS
mkdir -vp /data/config/comfy/
# cache
MOUNTS["/root/.cache"]=/data/.cache
# ui specific
MOUNTS["${ROOT}/models/checkpoints"]="/data/StableDiffusion"
MOUNTS["${ROOT}/models/controlnet"]="/data/ControlNet"
MOUNTS["${ROOT}/models/upscale_models/RealESRGAN"]="/data/RealESRGAN"
MOUNTS["${ROOT}/models/upscale_models/GFPGAN"]="/data/GFPGAN"
MOUNTS["${ROOT}/models/upscale_models/SwinIR"]="/data/SwinIR"
MOUNTS["${ROOT}/models/vae"]="/data/VAE"
# data
MOUNTS["${ROOT}/models/loras"]="/data/Lora"
MOUNTS["${ROOT}/models/embeddings"]="/data/embeddings"
# config
# TODO: I am not sure if this is final, maybe it should change in the future
MOUNTS["${ROOT}/models/clip"]="/data/.cache/comfy/clip"
MOUNTS["${ROOT}/models/clip_vision"]="/data/.cache/comfy/clip_vision"
MOUNTS["${ROOT}/models/custom_nodes"]="/data/config/comfy/custom_nodes"
MOUNTS["${ROOT}/models/style_models"]="/data/config/comfy/style_models"
MOUNTS["${ROOT}/models/t2i_adapter"]="/data/config/comfy/t2i_adapter"
# output
MOUNTS["${ROOT}/output"]="/output/comfy"
for to_path in "${!MOUNTS[@]}"; do
set -Eeuo pipefail
from_path="${MOUNTS[${to_path}]}"
rm -rf "${to_path}"
if [ ! -f "$from_path" ]; then
mkdir -vp "$from_path"
fi
mkdir -vp "$(dirname "${to_path}")"
ln -sT "${from_path}" "${to_path}"
echo Mounted $(basename "${from_path}")
done
exec "$@"

View File

@ -0,0 +1,46 @@
additionalProperties:
formFields:
- default: http://localhost:7890
edit: true
envKey: SD_CONSOLE_URL
labelEn: External URL
labelZh: 外部访问地址
required: true
rule: paramExtUrl
type: text
- default: 7890
edit: true
envKey: SD_CONSOLE_PORT
labelEn: Port
labelZh: 端口
required: true
rule: paramPort
type: number
- default: --listen --port 7890
edit: true
envKey: SD_CONSOLE_CLI_COMFY
labelEn: CLI_ARGS_for_Comfy
labelZh: COMFY的CLI_ARGS参数
required: true
type: text
- default: ""
edit: true
envKey: SD_CONSOLE_APT_COMFY
labelEn: APT_For_COMFY
labelZh: COMFY的APT参数
required: false
type: text
- default: ""
edit: true
envKey: SD_CONSOLE_PIP_COMFY
labelEn: PIP_For_COMFY
labelZh: COMFY的PIP参数
required: false
type: text
- default: 0
edit: true
envKey: SD_CONSOLE_DEVICE_IDS
labelEn: SD_CONSOLE_GPU_DEVICE_IDS
labelZh: SD运行指定的GPU设备ID
required: true
type: number

View File

@ -0,0 +1,41 @@
version: '3.9'
services:
a1111:
container_name: ${CONTAINER_NAME}
build: ./comfy
ports:
- "${SD_CONSOLE_PORT}:7890"
volumes:
- ./data:/data
- ./output:/output
stop_signal: SIGINT
environment:
# CLI_ARGS: Command Line Arguments.
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Command-Line-Arguments-and-Settings
# If you want, you can add other Command Line Arguments by referring to the link above.
# By default, it runs through `--opt-sdp-no-mem-attention` without using xformers.
# If you want, you can run it through xformers by deleting `--opt-sdp-no-mem-attention` and inserting `--xformers`.
- CLI_ARGS=${SD_CONSOLE_CLI_COMFY}
#--listen --port 7890 --enable-insecure-extension-access --api --theme=dark --no-half-vae --opt-sdp-no-mem-attention
# APT_ARGS, PIP_ARGS: This is where you write the apt and pip packages to install.
# Install some package if you want.
- APT_ARGS=${SD_CONSOLE_APT_COMFY}
# ex) APT_ARGS=package1 package2 ...
# equals apt-get install -y package1 package2 ...
- PIP_ARGS=${SD_CONSOLE_PIP_COMFY}
# ex) PIP_ARGS=package1 package2 ...
# equals pip install package1 package2 ...
# Tip: If you want to do "pip install -U SomePackage", you can do "-U SomePackage" on the PIP_ARGS.
# Like This: PIP_ARGS=-U SomePackage
# Same at "--user SomePackage"
# PIP_ARGS=--user SomePackage
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ['${SD_CONSOLE_DEVICE_IDS}']
capabilities: [gpu,compute,utility]

View File

@ -0,0 +1,2 @@
#!/bin/bash
docker compose up -d --build

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker compose build --no-cache
docker compose up -d