🎃

Windows ノートPCで省エネvramでWaifu Diffusionを実行する

2022/11/06に公開

Windows環境でAUTOMATIC1111氏のリポジトリの環境整備を進める
https://github.com/AUTOMATIC1111/stable-diffusion-webui

▼実行環境
Edition Windows 11 Pro
Version 21H2
OS build 22000.1098
Experience Windows Feature Experience Pack 1000.22000.1098.0

GPU:GTX 1060

1 リポジトリをcloneしておく

前回記事同様に前提条件としてUbuntuで適当なgit用リポジトリを作成してリポジトリはcloneされているものとします。

> git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

あとhugging faceからダウンロードしたモデルファイルをmodels/stable-diffusionフォルダ配下に置いておきます。
私はWaifu Diffusion v1.3 のfloat16のモデルを使ってみました。

▽ダウンロードは確かここから
https://huggingface.co/hakurei/waifu-diffusion-v1-3/blob/main/wd-v1-3-float16.ckpt

├───Stable-diffusion
│       Put Stable Diffusion checkpoints here.txt
│       wd-v1-3-float16.ckpt

2 私の場合はPython環境をあれこれ整備するのはAnacondaで仮想環境作っているのでWindows版Anaconda Navigatorをインストールする

https://www.anaconda.com/products/distribution

3 Anaconda PowerShell Promptを起動する

Anaconda PowerShell PromptはAnaconda Navigatorインストール時にデフォルトで一緒にインストールされたかと思います。

もしWebUIを動かすときにパッケージが足りない感じでしたらパッケージを一通りAnaconda環境でインストールしてみると動くかと思います。

> pip install -r requirements.txt

4 webui.batを実行

> cd stable-diffusion-webui
> ./webui.bat
venv "C:\Users\keigo\git\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]
Commit hash: 1fbfc052eb529d8cf8ce5baf578bcf93d0280c29
Installing requirements for Web UI
Launching Web UI with arguments:
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [84692140] from C:\Users\keigo\git\stable-diffusion-webui\models\Stable-diffusion\wd-v1-3-float16.ckpt
Global Step: 683410
Applying cross attention optimization (Doggettx).
Model loaded.
Loaded a total of 0 textual inversion embeddings.
Embeddings:
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.

5 http://127.0.0.1:7860 でサービスが動くのでアクセスしてプロンプトを入れて描画します


画像生成には20-30秒位かかりました。

6 描画中のvramは4.3GB位の消費でした

float16の精度のモデルであればGTX 1060でvram 6GB位のGPUでも512x512の画像生成に使えるようです。

Thanks

thanks to everyone behind these awesome projects,
First I would like to contribute the project by introducing best environment run with the user PC environment.
And I will contribute the democratized AI through this activity.

AUTOMATIC1111/stable-diffusion-webui

GitHubで編集を提案

Discussion