こちらはAMDのRadeonでStable Diffusionを試してみたい方向けの記事になります。NVIDIAのグラフィックボードでStable Diffusionを試してみたい方は以下の記事をご覧ください。
実行環境
今回使用するグラフィックボードは、VRAM8GBありますが古い世代の物になります。
OS | Windows11 |
グラフィックボード | RX480 8GB |
インストール
インストール手順は、NVIDIA環境とほとんど同じでクローンするリポジトリが違うだけです。RadeonではCUDAが使えないのでDirectML版を使用します。
Git インストール
GitHubからリポジトリをクローンするのに使います。
![gitダウンロード](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-3-800x368.webp)
Click here to downloadから最新版がダウンロードできます。ダウンロードしたら起動してください。
![Git Setup](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-4.webp)
特に設定する項目はないのでひたすらNextでSetupを進めてください。
Python 3.10.6 インストール
Pythonをインストールします。現在バージョンは3.10.6が指定されています。(マイクロバージョンは後方互換性が高いので新しいので大丈夫そうですが)
![Pythonダウンロード](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-1-800x282.webp)
Windows installer (64-bit) ダウンロードして起動
![Python 3.10.6 Setup](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-2.webp)
Add Python 3.10 to PATHにチェックを入れてインストールを進めてください。
ファイルのダウンロード
Gitコマンドでリポジトリをクローンします。
![ダウンロード場所](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-5-800x534.webp)
エクスプローラーでダウンロードしたい場所にアクセスしたらアドレスバーにcmdと入力してEnterでコマンドプロンプトを起動します。
下のコードを入力してEnter
git clone https://github.com/lshqqytiger/stable-diffusion-webui-directml && cd stable-diffusion-webui-directml && git submodule init && git submodule update
![Stable Diffusion Web UI AUTOMATIC1111 DirectML クローン](https://pcniki.com/wp-content/uploads/2023/10/amd-radeon-stable-diffusion-web-ui-automatic1111-directml-1-800x451.webp)
ファイルがダウンロードされます。
batファイル実行
![webui-user.bat 起動](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-7-800x534.webp)
ダウンロードされたフォルダ内のwebui-user.batを実行します。
![Stable diffusion Web UI インストール](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-8-800x418.webp)
初回起動時は、ファイルのダウンロードなどで時間がかかります。
![Stable diffusion Web UI 起動](https://pcniki.com/wp-content/uploads/2023/06/stable-diffusion-web-ui-automatic1111-install-9-800x418.webp)
正しくインストールされるとRunning on local URL: http://127.0.0.1:7860というメッセージが表示されブラウザが起動します。
生成結果
デフォルトでGenerateしたらRuntimeError: Not enough memory(メモリー不足)で生成できませんでした。メモリの使用量を削減できるコマンドライン引数を追加することで生成できるようになりました。
![Radeon コマンドライン引数](https://pcniki.com/wp-content/uploads/2023/10/amd-radeon-stable-diffusion-web-ui-automatic1111-directml-2.webp)
webui-user.batを編集して以下のコマンドライン引数を追加してください。
--medvram --opt-split-attention --opt-sub-quad-attention
![Stable Diffusion Web UI AUTOMATIC1111 DirectML](https://pcniki.com/wp-content/uploads/2023/10/amd-radeon-stable-diffusion-web-ui-automatic1111-directml-3-800x860.webp)
速度は512×512の20stepsで1枚約30秒ほどでした。Hires.fixは768×768まで可能でしたが、NVIDIAのグラフィックボードと比べるとパフォーマンスも悪く拡張機能がうまく機能しない場合もあります。やはりNVIDIAのグラフィックボード(VRAM12GB以上)に乗せ換えることをお勧めします。