【移行必須】Stable Diffusion WebUI Forgeを使ってみる

Stable Diffusion WebUI Forgeが公開されてから1ヶ月がたちましたが使っていて満足がいくツールだったので、遅らせばながら解説していきます。

結論: 今後はStable Diffusion WebUI Forgeで良い

Stable Diffusion WebUI Forgeですがめちゃくちゃ良いです。今のところ不具合もなくインストールもすでにStable Diffusion Web UIが入っているのであればgit cloneしてくるだけでOKです。そのうえ、速くなるのでStable Diffusion Web UI Forgeを使わないのは損。Stable Diffusion Web UI ForgeはStable Diffusion Web UIの置き換えを目指しているようなので、今後はStable Diffusion WebUI Forgeが主流になってくる予感がします。

インストール方法

Stable Diffusion WebUI Forgeの説明に入る前にいきなりですがインストール方法について解説します。インストールには少し時間がかかるのでインストールしている間に説明を読めるようにしています。不安な人は説明を読んでからインストールしてみてください。

Python,gitなどはすでにインストール済の状況を想定しております。Stable Diffusion Web UIをインストール済の方は環境はすでに構築されているので問題ありません。もしはじめてStable Diffusion Web UIをインストールする場合は必要な環境がすべて入るインストーラーも用意されているのでそちらを利用ください。

a. Stable Diffusion Web UIの環境が整っている方向け

1.ソースコードをクローンする

git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git

2.”stable-diffusion-webui-forge\webui.bat”をダブルクリックで起動

初回起動時はモデルのダウンロードやパッケージインストールのため20分弱かかります

b. Stable Diffusion Web UIの環境が整ってない場合

1. https://github.com/lllyasviel/stable-diffusion-webui-forgeへアクセスします。

2. 下にスクロールして”>>>Click Here to Download One-Click Package<<<“というリンクを見つけてファイルをダウンロードします。

3. ダウンロードした7zファイルを展開します。場所はどこでもよいですがこのフォルダwebui_forge_cu121_torch21はよく使うことになるので使いやすい場所に配置してください。

4. update.batを起動します。

5. run.batを押すとWeb UIが起動します。初回起動時は20分程度をかかります。今後はこのスクリプトでStable Diffusion Web UIを起動することになるので場所を忘れないように注意しましょう。

Stable Diffusion WebUI Forgeとは?

Stable Diffusion Web UI ForgeはStable Diffusion WebUIの一種です。名前の「Forge」は、「Minecraft Forge」から着想を得ていると言及されており、SD WebUIのForgeとなることを目指しているようです。つまり拡張性の高いStable Diffusion Web UIを目指しているということでしょう。

Stable Diffusion WebUI Forge is a platform on top of Stable Diffusion WebUI (based on Gradio) to make development easier, optimize resource management, and speed up inference.

The name “Forge” is inspired from “Minecraft Forge”. This project is aimed at becoming SD WebUI’s Forge.

https://github.com/lllyasviel/stable-diffusion-webui-forge

ちなみに製作者はStable Diffusion Web UIからControlNetを使う際にいつもお世話になっているsd-webui-controlnetの開発者でおなじみのlllyasviel氏です。Stable Diffusion Web UIの革命児ですね。

また公式の記載では次のようなパフォーマンス改善について言及されております。私自身の使用感でもかなり軽快に動作していて元のStable Diffusion Web UIには戻れなくなりました。

  • 一般的な8GB VRAMのGPUを使用する場合、推論速度(イテレーション/秒)が約30〜45%向上し、GPUメモリピーク(タスクマネージャーで)が約700MBから1.3GB減少し、最大の拡散解像度(OOMしない)が約2倍から3倍に増加し、最大の拡散バッチサイズ(OOMしない)が約4倍から6倍に増加します。
  • 6GB VRAMのより弱いGPUを使用する場合、推論速度(イテレーション/秒)が約60〜75%向上し、GPUメモリピーク(タスクマネージャーで)が約800MBから1.5GB減少し、最大の拡散解像度(OOMしない)が約3倍に増加し、最大の拡散バッチサイズ(OOMしない)が約4倍に増加します。
  • 24GB VRAMを持つ4090のような強力なGPUを使用する場合、推論速度(イテレーション/秒)が約3〜6%向上し、GPUメモリピーク(タスクマネージャーで)が約1GBから1.4GB減少し、最大の拡散解像度(OOMしない)が約1.6倍に増加し、最大の拡散バッチサイズ(OOMしない)が約2倍に増加します。
  • SDXL用のControlNetを使用する場合、最大のControlNet数(OOMしない)が約2倍に増加し、SDXL+ControlNetでの速度が約30〜45%向上します。
  1. If you use common GPU like 8GB vram, you can expect to get about 30~45% speed up in inference speed (it/s), the GPU memory peak (in task manager) will drop about 700MB to 1.3GB, the maximum diffusion resolution (that will not OOM) will increase about 2x to 3x, and the maximum diffusion batch size (that will not OOM) will increase about 4x to 6x.
  2. If you use less powerful GPU like 6GB vram, you can expect to get about 60~75% speed up in inference speed (it/s), the GPU memory peak (in task manager) will drop about 800MB to 1.5GB, the maximum diffusion resolution (that will not OOM) will increase about 3x, and the maximum diffusion batch size (that will not OOM) will increase about 4x.
  3. If you use powerful GPU like 4090 with 24GB vram, you can expect to get about 3~6% speed up in inference speed (it/s), the GPU memory peak (in task manager) will drop about 1GB to 1.4GB, the maximum diffusion resolution (that will not OOM) will increase about 1.6x, and the maximum diffusion batch size (that will not OOM) will increase about 2x.
  4. If you use ControlNet for SDXL, the maximum ControlNet count (that will not OOM) will increase about 2x, the speed with SDXL+ControlNet will speed up about 30~45%.
https://github.com/lllyasviel/stable-diffusion-webui-forge

あとは拡張性の高さについて言及されております。

Another very important change that Forge brings is Unet Patcher. Using Unet Patcher, methods like Self-Attention Guidance, Kohya High Res Fix, FreeU, StyleAlign, Hypertile can all be implemented in about 100 lines of codes.

Thanks to Unet Patcher, many new things are possible now and supported in Forge, including SVD, Z123, masked Ip-adapter, masked controlnet, photomaker, etc.

No need to monkeypatch UNet and conflict other extensions anymore!

medvramやxformersなどの最適化コマンドは?

Stable Diffusionには–medvramや–xformersなどの様々な高速化コマンドが用意されていましたが、Stable Diffusion Web UI Forgeでは廃止されています。引数を渡さなくてもすでに最適化されているため気にしないで良いです。

逆に最適化をしたくない場合はオフにするようなコマンドが用意されていますが、公式があまりおすすめしないと言及しています。

Again, Forge do not recommend users to use any cmd flags unless you are very sure that you really need these.

Again, Forge do not recommend users to use any cmd flags unless you are very sure that you really need these.

使用方法はStable Diffusion Web UIおなじ

こんな感じでStable Diffusion Web UIとUIが一緒なので同じように画像生成ができます。

コメント