CentOS上Stable Diffusion部署检查清单
一 环境基线核对
cat /etc/os-release;内核:uname -rnvidia-smi(右上显示Supported/Runtime CUDA)docker run --rm --gpus all nvidia/cuda:12.1.1-base-ubuntu22.04 nvidia-smi能正常输出python3 -V 或 python -Vdocker -v、docker info;若使用GPU,确认nvidia-container-toolkit已正确配置二 运行方式与端口连通性检查
ps -ef | grep -E 'webui|python',ss -ltnp | grep :7860curl -I http://127.0.0.1:7860;远程 curl -I http://服务器IP:7860docker run -d --gpus all -p 7860:7860 -v /path/to/models:/models automatic1111/stable-diffusion-webuidocker ps -a | grep stable-diffusion;日志:docker logs -f <容器名或ID>docker port <容器名或ID> 应显示7860/tcp -> 0.0.0.0:7860sudo firewall-cmd --list-ports,如未放行:sudo firewall-cmd --add-port=7860/tcp --permanent && sudo firewall-cmd --reloadgetenforce(返回Enforcing时,必要时为端口放行或临时setenforce 0验证是否为策略问题)三 模型与依赖完整性检查
~/stable-diffusion-webui/models/Stable-diffusion/sha256sum),避免中文或特殊字符路径python -m venv sd-venv && source sd-venv/bin/activatepip show torch torchvision torchaudio diffusers transformers accelerate xformerstorch为CUDA构建:python -c "import torch; print(torch.cuda.is_available())" 应为True四 服务健康监控与自恢复
pgrep -f "webui\.sh|python.*launch\.py" 或 pidof python3curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:7860,返回200为正常/usr/local/bin/sd-monitor.sh)#!/usr/bin/env bash
URL="http://127.0.0.1:7860"
LOG="/var/log/sd-monitor.log"
PID_FILE="/var/run/sd-webui.pid"
curl -s -o /dev/null -w "%{http_code}" "$URL" | grep -q "200"
if [ $? -ne 0 ]; then
echo "$(date) [WARN] WebUI not healthy, restarting..." >> "$LOG"
pkill -f "webui\.sh|python.*launch\.py" || true
cd /home/sd/stable-diffusion-webui && nohup ./webui.sh --listen >> "$LOG" 2>&1 &
echo $! > "$PID_FILE"
else
echo "$(date) [OK] WebUI is healthy." >> "$LOG"
fiecho "*/2 * * * * root /usr/local/bin/sd-monitor.sh" | sudo tee /etc/cron.d/sd-monitor >/dev/nullsudo systemctl enable --now sd-monitor.service,查看状态:systemctl status sd-monitor.service,日志:journalctl -u sd-monitor.service -f五 常见故障快速定位
ss -ltnp | grep 7860;容器未映射:检查-p 7860:7860nvidia-smi异常:重装驱动或检查nvidia-container-toolkittorch与驱动/CUDA版本匹配;必要时重装对应版本以上步骤覆盖了系统、容器、网络、模型与监控五个维度,按序执行可快速判定Stable Diffusion在CentOS上的部署是否健康,并定位常见问题。