报错如下
e `style` method is deprecated. Please set these arguments in the constructor instead.
with gr.Row().style(equal_height=False):
/root/autodl-tmp/Stable-Diffusion-WebUI/webui/extensions/sd-webui-additional-networks/scripts/metadata_editor.py:521: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
cover_image = gr.Image(
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Startup time: 115.5s (prepare environment: 87.4s, import torch: 7.7s, import gradio: 1.7s, setup paths: 8.8s, initialize shared: 0.2s, other imports: 0.5s, load scripts: 4.1s, create ui: 3.6s, gradio launch: 1.4s).
5493a0ec491f5961dbdc1c861404088a6ae9bd4007f6a3a7c5dee8789cdc1361
Loading weights [5493a0ec49] from /root/autodl-tmp/Stable-Diffusion-WebUI/webui/models/Stable-diffusion/AbyssOrangeMix3_AOM3A1B.safetensors
Creating model from config: /root/autodl-tmp/Stable-Diffusion-WebUI/webui/configs/v1-inference.yaml
/root/miniconda3/envs/sd-py310/lib/python3.10/site-packages/huggingface_hub/file_download.py:943: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
warnings.warn(
webui.sh: line 67: 17014 Killed "${PYTHON}" launch.py "$@"
启动完成
解决方案
从报错信息来看,核心问题是 进程被系统强制终止(Killed),具体发生在加载模型并初始化时。这通常是由于 内存(RAM)或显存(VRAM)不足 导致的,系统的 OOM(Out Of Memory)管理器会终止占用资源过高的进程以保护系统稳定。以下是具体分析和解决办法:
一、核心原因:资源不足
内存(RAM)不足
Stable Diffusion 加载大模型(如你使用的AbyssOrangeMix3_AOM3A1B.safetensors
通常几 GB)时,会占用大量内存。如果 AutoDL 实例的内存(如 4GB/8GB)不足以支撑模型加载和初始化,系统会直接终止进程,出现 “Killed” 错误。显存(VRAM)不足
若使用 GPU 加速,显存不足也可能导致崩溃,但 “Killed” 更常见于内存不足(显存不足通常会报CUDA out of memory
错误)。
二、解决步骤
1. 检查资源使用情况
启动前先查看当前内存和显存占用,确认是否不足:
# 查看内存使用(total 是总内存,available 是可用内存)
free -h
# 查看显存使用(需有 GPU)
nvidia-smi
- 如果内存
available
低于模型大小(如模型 4GB,可用内存仅 2GB),则肯定是内存不足。 - 显存若低于模型推荐值(如 4GB 模型至少需要 6GB 显存),也可能触发问题。
2. 减少内存/显存占用(关键)
通过添加启动参数降低资源需求,修改 webui.sh
或启动命令,加入以下参数:
参数 | 作用 | 适用场景 |
---|---|---|
--lowvram |
低内存模式,分阶段加载模型到显存 | 显存 < 4GB |
--medvram |
中等内存模式,平衡速度和内存占用 | 显存 4-8GB |
--no-half |
禁用 FP16 半精度(用 FP32,精度高但占用高,不推荐) | 仅作为最后尝试 |
--disable-nan-check |
禁用数值检查,减少少量内存占用 | 内存略不足时 |
示例:在 webui.sh
中修改启动命令,添加 --medvram
:
# 原启动行(约 line 67)
"${PYTHON}" launch.py "$@"
# 修改后
"${PYTHON}" launch.py --medvram "$@"
3. 关闭其他占用资源的进程
AutoDL 实例中可能有其他后台进程占用内存,用 top
或 htop
查看并关闭:
# 查看进程占用情况(按 M 排序内存占用)
top
# 找到高占用进程(如 PID 为 1234),终止它
kill -9 1234
4. 更换更小的模型或调整配置
- 若模型过大(如 7GB+),尝试换成轻量模型(如 2-4GB 的模型,如
v1-5-pruned.safetensors
)。 - 降低图像生成参数(如分辨率从 512x512 降至 384x384),减少运行时内存需求。
5. 升级 AutoDL 实例配置
如果以上方法无效,说明当前实例的内存/显存不足以支撑运行,需在 AutoDL 控制台重新选择 更高配置的实例(如内存 16GB+、显存 8GB+)。
三、其他警告处理(不影响运行)
日志中的警告信息(如 GradioDeprecationWarning
、FutureWarning
)是工具库的版本兼容提示,不影响核心功能,可忽略或通过升级对应库解决:
# 升级 gradio 和 huggingface_hub 到最新版
pip install --upgrade gradio huggingface_hub
总结:“Killed” 主要是内存/显存不足导致,优先通过 --medvram
等参数降低资源需求,或升级实例配置,即可解决问题。