【Stable Diffusion】バージョンが違うから WebUI が使えない

エンタメ
記事内に広告が含まれています。
スポンサーリンク

追記 4/23 Google Colabでstable-diffusion-webuiの文字を含む関数を実行しようとすると警告が出るようになっています。

スポンサーリンク

WebUI を使えない時に出ていたエラー

4/3は普通に使えていた Stable Diffusion がなぜかうまく使えなくなっていました。(Google Colab での環境)

どうやら Launching WebUI でめちゃくちゃ時間がかかってエラーを吐いているようです。

エラーはこんな感じでした。

Launching Web UI with arguments: –share –xformers –enable-insecure-extension-access –gradio-queue –no-half-vae Traceback (most recent call last): File “/content/stable-diffusion-webui/launch.py”, line 361, in <module> start() File “/content/stable-diffusion-webui/launch.py”, line 352, in start import webui File “/content/stable-diffusion-webui/webui.py”, line 15, in <module> from modules import import_hook, errors, extra_networks, ui_extra_networks_checkpoints File “/content/stable-diffusion-webui/modules/ui_extra_networks_checkpoints.py”, line 6, in <module> from modules import shared, ui_extra_networks, sd_models File “/content/stable-diffusion-webui/modules/shared.py”, line 12, in <module> import modules.interrogate File “/content/stable-diffusion-webui/modules/interrogate.py”, line 11, in <module> from torchvision import transforms File “/usr/local/lib/python3.9/dist-packages/torchvision/__init__.py”, line 6, in <module> from torchvision import datasets, io, models, ops, transforms, utils File “/usr/local/lib/python3.9/dist-packages/torchvision/datasets/__init__.py”, line 1, in <module> from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel File “/usr/local/lib/python3.9/dist-packages/torchvision/datasets/_optical_flow.py”, line 12, in <module> from ..io.image import _read_png_16 File “/usr/local/lib/python3.9/dist-packages/torchvision/io/__init__.py”, line 8, in <module> from ._load_gpu_decoder import _HAS_GPU_VIDEO_DECODER File “/usr/local/lib/python3.9/dist-packages/torchvision/io/_load_gpu_decoder.py”, line 1, in <module> from ..extension import _load_library File “/usr/local/lib/python3.9/dist-packages/torchvision/extension.py”, line 107, in <module> _check_cuda_version() File “/usr/local/lib/python3.9/dist-packages/torchvision/extension.py”, line 80, in _check_cuda_version raise RuntimeError( RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=11.7 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.

めちゃくちゃ長いので見るのも嫌になりますが、重要な部分は最後のこの部分です。

RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=11.7 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.

要するに PyTorch と torchvision が異なる CUDA バージョンでコンパイルされているので PyTorch と同じバージョンの torchvision をインストールしろ。って話になります。

解決策

githubで同じエラーにぶち当たってる人がいたらしく解決法も載ってました。

[Bug]: RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. · Issue #9341 · AUTOMATIC1111/stable-diffusion-webui
Is there an existing issue for this? I have searched the existing issues and checked the recent builds/commits What happ...

上に書いた通り PyTorch と torchvision のバージョンを合わせる必要があります。

!pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117

githubのページに書いてあることそのままですが、こいつを実行すれば起動するようになります。(!python launch.pyの前とかに置いとけばいいです)

やってること的には、cu117は、CUDA 11.1を使用するということなので、
torch==1.13.1+cu117であれば、CUDA 11.1のtorchのバージョンは1.13.1を指定するという意味です。
他も同じようにCUDA 11.1で指定したバージョンの物を落としてこいという命令になります。

urlの指定はそのまんま落としてきてほしいものが置いてあるURLです。

このpip installをやっておくことでバージョンが一致するようになり無事 WebUI が起動するようになります。

おまけ checkpoint にエラーが出ている

無事起動はできるようになっていますが、なぜかちゃんとモデルデータを落としてきていても checkpoint に Error と表示されるようになりました。

エラー表示の理由はわかりませんが、右側にある更新ボタンを押すことでちゃんと読み込まれるので押しておきましょう。

最後のまとめ

今回は「【Stable Diffusion】バージョンが違うから WebUI が使えない」というタイトルで WebUI のランタイムエラーの解決策を書きました。

4/4から Google Colab で WebUI を使って Stable Diffusion を遊んでいた人はランタイムエラーで WebUI が起動できなくなっているかもしれません。

RuntimeError: Detected that PyTorch and torchvision were compiled with different CUDA versions. PyTorch has CUDA Version=11.7 and torchvision has CUDA Version=11.8. Please reinstall the torchvision that matches your PyTorch install.

のエラーが出るようになっている人は

!pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117

を実行しておきましょう。

バージョンを合わせるために落としてくるもののバージョンを指定してるコードですが、おまじないだと思っておいていいと思います。

まあgitHubに同じことに直面した人の質問と回答があったのでそれ持ってきてちょっと付けた足しただけですが…

githubのページは英語のページに拒否反応を示して見れない人とかいるかもしれないし、たどり着かない人もいるかもしれないしまあいいでしょ。

こんな記事も書いています。

学習済みのファイルがうまく適応されない場合はこちらもどうぞ。

大きい画像が欲しい人はこちらもどうぞ

コメント

タイトルとURLをコピーしました