0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[完全版] Windowsでxformersまで含めたStable Diffusion Web UI 完全セットアップ

Last updated at Posted at 2025-03-01

【完全解説】Stable Diffusion Web UI を Windows 11 (CUDA 12.4) にセットアップする方法

Stable Diffusion は、AI を活用した画像生成ツールであり、高品質なイラストや写真風の画像を作成できることで人気です。本記事では、Stable Diffusion Web UI を Windows 11 + CUDA 12.4 環境 にセットアップする方法を解説します。
今まで面倒であったライブラリ依存関係の問題を全て飛ばして一発で環境構築が完了します。
GeForce RTX 4090 Laptop GPU 環境での動作確認済み! 🚀


🎥 使用環境

環境 詳細
GPU GeForce RTX 4090 Laptop
OS Windows 11
Python 3.10.6
CUDA 12.4

1⃣ Visual Studio Build Tools のインストール

Stable Diffusion を正常に動作させるために、Visual Studio Build Tools をインストールします。

📌 手順

  1. Visual Studio Build Tools をダウンロード

  2. インストーラーを実行し、以下の項目を選択

    • 「C++ によるデスクトップ開発」を選択
    • 右側の「インストールの詳細」で、以下の項目にチェックを入れる:
      • C++ Build Tools コア機能
      • MSVC v143 - VS 2022 C++ x64/x86 ビルドツール
      • Windows 11 SDK (10.0.22621.0)
      • Windows 用 C++ CMake ツール
  3. インストールを実行

    • 右下の「ダウンロードしながらインストールする」をクリックしてインストール開始

2⃣ Python 3.10.6 のインストール

Stable Diffusion の実行には Python 3.10.6 が最適とされています。これは、Stable Diffusion Web UI の依存関係と互換性が高く、動作が安定しているためです。他のバージョンではエラーが発生する可能性があるため、特に理由がない限り 3.10.6 を使用することを推奨します。

Stable Diffusion の実行に適した Python 3.10.6 をインストールします。

📌 手順

  1. Python のダウンロード

    • Python公式サイト にアクセス
    • 「Windows installer (64-bit)」を選択してダウンロード
  2. インストーラーを実行し、以下の設定を適用

    • 「Add Python to environment variables」にチェックを入れる(環境変数に追加)
    • 「Install Now」をクリックしてインストール開始
  3. インストールを確認

    python --version
    

    Python 3.10.6 と表示されれば OK ✅


3⃣ CUDA 12.4 のインストール

Stable Diffusion の GPU を活用するために、CUDA 12.4 をインストールします。他のバージョンの CUDA を使用すると、互換性の問題が発生する可能性があるため、特に理由がない限り 12.4 を推奨します。

Stable Diffusion の GPU を活用するために、CUDA 12.4 をインストールします。

📌 手順

  1. CUDA をダウンロード

    • NVIDIA公式サイト にアクセス
    • 「CUDA Toolkit 12.4」を選択し、Windows 用のインストーラーをダウンロード
  2. インストーラーを実行し、デフォルト設定でインストール

  3. インストールを確認

    nvcc --version
    

    release 12.4 と表示されれば OK ✅


4⃣ Stable Diffusion Web UI を GitHub からクローンする

まず、stable-diffusion-webui を GitHub からクローンします。

📌 手順

  1. Git をインストール(未インストールの場合)

  2. PowerShell またはコマンドプロンプト を開き、以下のコマンドを実行

    git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
    
  3. クローンしたディレクトリへ移動

    cd stable-diffusion-webui
    

5⃣ Windows 用 Triton を手動インストール

Triton は、Stable Diffusion で xformers を使用する際に必要なコンパイル済みの GPU 最適化ライブラリです。Windows 版は公式に提供されていないため、手動でインストールする必要があります。

Stable Diffusion で xformers を使用するために Windows 用 Triton を手動でインストールします。

📌 手順

  1. 以下のページから Triton をダウンロード

  2. ダウンロードフォルダへ移動

    cd [ダウンロードしたフォルダのパス]
    
  3. Triton をインストール

    pip install triton-3.2.0-cp310-cp310-win_amd64.whl
    

6⃣ requirements.txt を更新 (ここが重要)

It's confirmed perfect requirements.txt [2025/03/01]

  1. stable diffusion フォルダ配下の`requirements.txt`を開きます(エディタは何でもよいです。)
  2. 以下のテキストを編集して保存します
GitPython
Pillow
accelerate

blendmodes
clean-fid
diskcache
einops
facexlib
fastapi>=0.90.1
gradio==3.41.2
inflection
jsonmerge
kornia
lark
numpy
omegaconf
open-clip-torch

piexif
protobuf==3.20.0
psutil==5.9.6
pytorch_lightning
requests
resize-right

safetensors
scikit-image>=0.19
tomesd
torch==2.6.0+cu124
torchvision==0.21.0+cu124
torchaudio==2.6.0+cu124
torchdiffeq
torchsde
transformers==4.30.2
pillow-avif-plugin==1.4.3

pydantic==1.10.13
markupsafe==2.0.1
xformers==0.0.29.post3

--index-url https://download.pytorch.org/whl/cu124

こんな感じになるはずです。
kh4v2xfn.png


7⃣ Python 仮想環境 (venv) を作成

python -m venv venv
venv\Scripts\Activate.ps1

8⃣ WebUI を起動

./webui.bat

🌟 お疲れ様でした!

開かれたStable Diffusion Web UIの画面下に以下のように表示されると成功です
スクリーンショット (72).png

  • version: v1.10.1
  • python: 3.10.6
  • torch: 2.6.0+cu124
  • xformers: 0.0.29.post3
  • gradio: 3.41.2
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?