1
0

【Stable Diffusion WebUI】エラー「failed assertion `commit command buffer with uncommitted encoder'」の原因

Posted at

エラー概要

以前まで普通にStable Diffusion WebUIを使えていたのに、なぜかとある日以下のエラーになった。無事に解決できたので共有します。

To create a public link, set `share=True` in `launch()`.
Startup time: 14.1s (launcher: 0.7s, import torch: 5.8s, import gradio: 1.6s, setup paths: 2.0s, other imports: 3.3s, load scripts: 0.3s, create ui: 0.2s).
Creating model from config: /Users/xxx/xxxx/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/configs/stable-diffusion/v2-inference-v.yaml
LatentDiffusion: Running in v-prediction mode
DiffusionWrapper has 865.91 M params.
Applying attention optimization: InvokeAI... done.
-[IOGPUMetalCommandBuffer validate]:200: failed assertion `commit command buffer with uncommitted encoder'
./webui.sh: line 254: 56657 Abort trap: 6           "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"

webui-macos-env.shCOMMANDLINE_ARGSは以下で実施していました。

export COMMANDLINE_ARGS="--skip-torch-cuda-test --upcast-sampling --no-half-vae --no-half --use-cpu interrogate --lowvram"

Mac環境

機種ID:MacBookPro18,3
macOS:Monterey
チップ:Apple M1 Pro
メモリ:16GB

エラーの原因

エラーメッセージは、GPUのメモリが不足している、GPUのコマンドバッファが適切にコミットされていない、などの理由があると言っているっぽい。

PyTorchが使用するGPUメモリの最大量を制御することでメモリ不足によるエラーを回避することができるらしい。

MPS backend out of memoryというエラーが出た場合も同様の原因であるらしく、こちらも参考になりました。

MPS backend out of memory #9133

解決方法

PyTorchが使用するGPUメモリの最大量はPYTORCH_MPS_HIGH_WATERMARK_RATIOで設定できます。1に近いほどGPUメモリを使用します。デフォルトでは1になっている。

ということで、webui-user.shに以下を追加したらエラーがなくなりました。

# PyTorch settings
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.7
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0