PaperspaceでAUTOMATIC1111/stable-diffusion-webui v1.6 を動かす
v1.6 が出たので、Paperspaceで動かしてみます。手順は v1.5.1 と同じです。v1.5.1 の時の手順は以下です。
AUTOMATICE1111のダウンロード
今回はDISK節約のため、v1.5.1 のときに作成したモデルは削除し、新たに作成しなおしました。手順は前回と同様、@javacommonsさんの記事(【Paperspace】Stable Diffusion Web UI を月額定額で使う )に沿って進めます。
新しいプロジェクト、ノートブックを作成し、設定用のファイル(webui2.ipynb)をアップロードし、順番に実施します。
#(1) AUTOMATIC1111のダウンロード
%cd /notebooks
!rm -rf stable-diffusion-webui
!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
/notebooks
Cloning into 'stable-diffusion-webui'...
remote: Enumerating objects: 27104, done.
remote: Counting objects: 100% (529/529), done.
remote: Compressing objects: 100% (267/267), done.
remote: Total 27104 (delta 328), reused 407 (delta 262), pack-reused 26575
Receiving objects: 100% (27104/27104), 32.16 MiB | 56.98 MiB/s, done.
Resolving deltas: 100% (18961/18961), done.
モデルのダウンロードは後にして、起動してバージョンを確認してみます。
#(3) WebUI起動
!apt update
!apt -y install python3.10
!apt -y install libpython3.10-dev
!apt -y install build-essential
!curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
!python3.10 -m pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1+cu118 torchtext==0.15.1 torchdata==0.6.0 --extra-index-url https://download.pytorch.org/whl/cu118 -U
!python3.10 -m pip install xformers==0.0.18 triton==2.0.0 -U
!python3.10 -m pip install matplotlib -U
!python3.10 -m pip install ipython -U
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'inline')
%cd /notebooks/stable-diffusion-webui
!python3.10 launch.py --xformers --enable-insecure-extension-access --share --gradio-queue
起動画面を見ると、確かに V1.6.0 になっています。
モデルの配置
モデルはBDさんの BreakDomainXL_V04a 使わせていただきます。
ローカルにダウンロードして、GoogleDriveに置いて、Paperspaceからgdownでダウンロードします。(gdown のインストールから実施)
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/Stable-diffusion# pip install gdown
Requirement already satisfied: gdown in /usr/local/lib/python3.10/dist-packages (4.7.1)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from gdown) (3.12.3)
Requirement already satisfied: requests[socks] in /usr/local/lib/python3.10/dist-packages (from gdown) (2.31.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from gdown) (1.14.0)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from gdown) (4.66.1)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from gdown) (4.12.2)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->gdown) (2.5)
Requirement already satisfied: typing-extensions>=4.7.1 in /usr/local/lib/python3.10/dist-packages (from filelock->gdown) (4.7.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests[socks]->gdown) (2.8)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests[socks]->gdown) (2019.11.28)
Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (1.7.1)
DEPRECATION: torchsde 0.2.5 has a non-standard dependency specifier numpy>=1.19.*; python_version >= "3.7". pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of torchsde or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/Stable-diffusion# pip install --upgrade gdown
Requirement already satisfied: gdown in /usr/local/lib/python3.10/dist-packages (4.7.1)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from gdown) (3.12.3)
Requirement already satisfied: requests[socks] in /usr/local/lib/python3.10/dist-packages (from gdown) (2.31.0)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from gdown) (1.14.0)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from gdown) (4.66.1)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.10/dist-packages (from gdown) (4.12.2)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4->gdown) (2.5)
Requirement already satisfied: typing-extensions>=4.7.1 in /usr/local/lib/python3.10/dist-packages (from filelock->gdown) (4.7.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (3.2.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests[socks]->gdown) (2.8)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (1.26.16)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests[socks]->gdown) (2019.11.28)
Requirement already satisfied: PySocks!=1.5.7,>=1.5.6 in /usr/local/lib/python3.10/dist-packages (from requests[socks]->gdown) (1.7.1)
DEPRECATION: torchsde 0.2.5 has a non-standard dependency specifier numpy>=1.19.*; python_version >= "3.7". pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of torchsde or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/Stable-diffusion# gdown '1ksBj33vfL5n4thnw_jLP4to8cY17q67G&confirm=t'
Downloading...
From: https://drive.google.com/uc?id=1ksBj33vfL5n4thnw_jLP4to8cY17q67G&confirm=t
To: /notebooks/stable-diffusion-webui/models/Stable-diffusion/_BreakDomainXL_V04a.safetensors
100%|██████████████████████████████████████████████████████████████████████████████████████| 6.94G/6.94G [01:18<00:00, 88.5MB/s]
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/Stable-diffusio#
同様にVAEもダウンロードします。
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/VAE# gdown '1ZyA5U8LUOvsxVch_3XuFVeg5RhErNBVn&confirm=t'
Downloading...
From: https://drive.google.com/uc?id=1ZyA5U8LUOvsxVch_3XuFVeg5RhErNBVn&confirm=t
To: /notebooks/stable-diffusion-webui/models/VAE/sdxl_vae.safetensors
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████| 335M/335M [00:05<00:00, 62.0MB/s]
root@nmurl7i6sc:/notebooks/stable-diffusion-webui/models/VAE#
追加設定
メニューに表示する項目を追加します。
Settings → User Interface の Quicksetting list に「sd_vae」「CLIP_stop_al_last_layers」を追加して、Apply Settings + Reload UI します。
結果、項目が画面に追加されました。
画像生成
生成してみると、これまでと同様でした。
新しいバージョンで追加されている内容については、追々、確認していきます。
xformersのバージョンアップ対応(2023-09-10追記)
起動時のメッセージに以下が出ていました。
Launching Web UI with arguments: --xformers --enable-insecure-extension-access --share --gradio-queue
=================================================================================
You are running xformers 0.0.18.
The program is tested to work with xformers 0.0.20.
To reinstall the desired version, run with commandline flag --reinstall-xformers.
Use --skip-version-check commandline argument to disable this check.
=================================================================================
xFormsとは、Googleの生成AIの回答によると、『画像生成や自然言語処理などのタスクを高速化するために開発された PyTorch ベースのライブラリです。xFormers は、NVIDIA の GPU でのみ動作し、画像生成速度を大幅に向上させながら、VRAM の消費を抑えることができます。』とのことです。
指示通りにWebUI起動コマンドに追記します。
(追記前)
!python3.10 launch.py --xformers --enable-insecure-extension-access --share --gradio-queue
(追記後)
!python3.10 launch.py --xformers --enable-insecure-extension-access --share --gradio-queue --reinstall-xformers
これで起動すると、先ほどのメッセージは出なくなりました。他にも出ていますが、別途確認します。
Launching Web UI with arguments: --xformers --enable-insecure-extension-access --share --gradio-queue --reinstall-xformers
Loading weights [3b0e33f668] from /notebooks/stable-diffusion-webui/models/Stable-diffusion/_BreakDomainXL_V04a.safetensors
/notebooks/stable-diffusion-webui/extensions/sdweb-easy-prompt-selector/scripts/easy_prompt_selector.py:97: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
reload_button.style(size='sm')
Running on local URL: http://127.0.0.1:7860
Creating model from config: /notebooks/stable-diffusion-webui/repositories/generative-models/configs/inference/sd_xl_base.yaml
Loading VAE weights specified in settings: /notebooks/stable-diffusion-webui/models/VAE/sdxl_vae.safetensors
Applying attention optimization: xformers... done.
Model loaded in 9.4s (load weights from disk: 2.3s, load config: 0.3s, create model: 0.8s, apply weights to model: 4.5s, apply half(): 0.1s, load VAE: 0.4s, calculate empty prompt: 0.7s).
Running on public URL: https://***************.gradio.live
同じ条件で生成してみます。
生成時間が特に違いは感じませんでした。18 と 20 の違いだから小さいのかもしれません。生成された画像は若干異なりました。全く同じ画像が生成されると思っていたので、以外でした。他の画像も生成して、色々見てみます。
この記事が気に入ったらサポートをしてみませんか?