最近的AI绘画可谓是特别火呀,这一期带大家使用容器搭建Stable-Diffusion
1.首先我们安装Docker
Debian
sudo apt update && sudo apt install -y docker.io
Redhat
sudo yum makecache && sudo yum install -y podman
2.我们拉取debian镜像
Debian
docker pull debian
RHEL
podman pull debian
3.开始构造镜像
docker run -p 1234:1234 -itd --name stable debian
podman run -p 1234:1234 -itd --name stable debian
docker exec -it stable bash
podman exec -it stable bash
sudo apt update && sudo apt install -y python3 python3-pip python3-venv git \
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install torch \
&& pip install torchvision \
&& pip install gfpgan \
&& pip install clip
&& pip install opencv-python-headless
&& git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui \
4.复制模型进去
docker/podman cp models stable:/stable-diffusion-webui-master/models/
5.运行容器内的SD
普通显卡
python3 launch.py --port 1234 --listen
CPU硬解
export COMMANDLINE_ARGS=--skip-torch-cuda-test
python3 launch.py --no-half --port 1234 --listen