概要
NVIDIA GeForce RTX 5060Ti 16GB のグラフィックカードを使って、Stability Matrix で導入した Stable Diffusion WebUI (AUTOMATIC1111 版) での画像生成を試みましたが、エラーとなりました。
対処法などについて記載します。
結論
結論から言うと、PyTorch と xformers のアップデート(インストール) が必要です。
コマンドプロンプトを管理者権限で起動して以下 4行を実行します。
(C:\StabilityMatrix に Stability Matrix をインストールしている場合)
cd C:\StabilityMatrix\Data\Packages\stable-diffusion-webui .\venv\Scripts\activate.bat pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu128
詳細は以下に記載します。
現象
以前、NVIDIA GeForce RTX 3050 の環境で Stability Matrix を用いて Stable Diffusion の実行環境を作成しました。
新しく作成した自作 PC (NVIDIA GeForce RTX 5060Ti 16GB 搭載) に、同様に環境を作成し、 Stable Diffusion WebUI (AUTOMATIC1111 版) で画像生成を試みましたが、エラーとなりました。
エラーは、WebUI を起動し Generate をクリックした後に発生します。

エラー内容:
RuntimeError: CUDA error: no kernel image is available for execution on the device CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
警告とエラー、トラブルシュート
上記のエラーメッセージの通り、CUDA での実行の際に問題があったと考えられます。
調査を進めたところ、表示が流れてしまい当初確認していなかったのですが、実は Stability Matrix で Stable Diffusion WebUI (AUTOMATIC1111 版) を起動する時点で、警告が発生していたことがわかりました。

Stability Matrix のパッケージ起動時のコンソールの警告:
C:\StabilityMatrix\Data\Packages\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\__init__.py:215: UserWarning:
NVIDIA GeForce RTX 5060 Ti with CUDA capability sm_120 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_50 sm_60 sm_61 sm_70 sm_75 sm_80 sm_86 sm_90.
If you want to use the NVIDIA GeForce RTX 5060 Ti GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
インストールされている PyTorch が RTX 5060Ti の CUDA capability sm_120 に対応してないよ という内容です。
sm_120 に対応した PyTorch のインストール
まずは、sm_120 に対応している PyTorch へとアップデート(インストール)しました。
Stability Matrix でインストールされる Stable Diffusion WebUI (AUTOMATIC1111 版) は、venv による Python の仮想実行環境で用意されていることがポイントです。
順番に記載していきます。
Stable Diffusion WebUI (AUTOMATIC1111 版) を停止
もし、Stable Diffusion WebUI (AUTOMATIC1111 版) が開始されているのであれば、停止しておきます。
PyTorch インストール用のコマンドの作成
コンソールの警告にある https://pytorch.org/get-started/locally/ にアクセスします。

Start Locally にある5つの選択項目で以下を選び、コマンドを作成します。

項目 | 選択したもの |
---|---|
PyTorch Build | Stable (2.7.0) |
Your OS | Windows |
Package | Pip |
Language | Python |
Compute Platform | CUDA 12.8 |
上記を選択後、Run this Command: に以下が表示されるのでコピーしておきます。
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
コマンドの実行
管理者権限でコマンドプロンプトを開きます。
[スタート] – “コマンドプロンプト” で検索 – [コマンドプロンプト] – [管理者として実行]
注) ターミナルだと PowerShell が実行されてしまうので、今回に限ってはコマンドプロンプトの方が都合がよいです。
開いたコマンドプロンプトで、”Stability Matrix がインストールされているフォルダ”\Data\Packages\stable-diffusion-webui に cd で移動します。
例)
C:\StabilityMatrix にインストールしてある場合cd C:\StabilityMatrix\Data\Packages\stable-diffusion-webui

次に、Python の venv を activate します。(activate という拡張子無しのシェルスクリプトもあるので、.bat まで明記して実行します。).\venv\Scripts\activate.bat

プロンプトの頭に (venv) が付きます。

上記(1) でコピーしたコマンドを実行します。pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128



最下部に Successfully installed torch-…. と、その上に以下のエラーが表示されました。
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
xformers 0.0.23.post1 requires torch==2.1.2, but you have torch 2.7.0+cu128 which is incompatible.
この xformers のエラーについても対処が必要そうなので、さらなるトラブルシューティングを行いました。
補足) : (venv) のプロンプトになっているコマンドプロンプトは閉じずにそのままにしておくと後で都合がよいです。
PyTorch インストール後、試しに起動してみる
Stable Diffusion WebUI (AUTOMATIC1111 版) を開始
エラーが出ていますが、試しに Stability Matrix で Stable Diffusion WebUI (AUTOMATIC1111 版) を開始してみました。
ポップアップが出ますが、OK をクリックすると、一応 WebUI は起動します。


Prompt を入力して Generate をクリックすると次のエラーで画像生成が失敗します。

NotImplementedError: No operator found for `memory_efficient_attention_forward` with inputs: query : shape=(1, 4096, 1, 512) (torch.float16) key : shape=(1, 4096, 1, 512) (torch.float16) value : shape=(1, 4096, 1, 512) (torch.float16) attn_bias : <class 'NoneType'> p : 0.0 `decoderF` is not supported because: max(query.shape[-1] != value.shape[-1]) > 128 xFormers wasn't build with CUDA support attn_bias type is <class 'NoneType'> operator wasn't built - see `python -m xformers.info` for more info `flshattF@0.0.0` is not supported because: max(query.shape[-1] != value.shape[-1]) > 256 xFormers wasn't build with CUDA support operator wasn't built - see `python -m xformers.info` for more info `tritonflashattF` is not supported because: max(query.shape[-1] != value.shape[-1]) > 128 xFormers wasn't build with CUDA support operator wasn't built - see `python -m xformers.info` for more info triton is not available `cutlassF` is not supported because: xFormers wasn't build with CUDA support operator wasn't built - see `python -m xformers.info` for more info `smallkF` is not supported because: max(query.shape[-1] != value.shape[-1]) > 32 xFormers wasn't build with CUDA support dtype=torch.float16 (supported: {torch.float32}) operator wasn't built - see `python -m xformers.info` for more info unsupported embed per head: 512
やっぱり、xformers のエラーは解消しないといけませんでした。
Stability Matrix のコンソールを確認すると、Stable Diffusion WebUI (AUTOMATIC1111 版) の開始時に以下の警告が出ていることが確認できました。

WARNING:xformers:WARNING[XFORMERS]: xFormers can't load C++/CUDA extensions. xFormers was built for:
PyTorch 2.1.2+cu121 with CUDA 1201 (you have 2.7.0+cu128)
Python 3.10.11 (you have 3.10.11)
Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
xformers のインストール
この xformers のエラーについても対処します。
Stable Diffusion WebUI (AUTOMATIC1111 版) を停止
動かしたままだとファイルの更新や削除でエラーが発生するので、再度停止します。
対応した xformers のインストール
上記の警告に表示されているサイト https://github.com/facebookresearch/xformers#installing-xformers にアクセスします。

Installing xFormers にある cuda 12.8 version 用のコマンドをコピーします。pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu128
開いたままにしている (venv) のプロンプトになっているコマンドプロンプトで、↑でコピーしたコマンドを実行してxformers をインストールします。

最後に Successfully installed xformers が表示されることを確認します。

新しいバージョンの PyTorch と xformers をインストール後に試す
再度、Stability Matrix で Stable Diffusion WebUI (AUTOMATIC1111 版) を開始します。
WebUI で Prompt を入力し、画像が生成できることを確認します。

以上、参考となれば幸いです。
▼ 関連