IT/ICT

Stable Diffusionローカル環境構築 memo

Stable Diffusion & AUTOMATIC1111 memo

RTX5070を搭載したPCで、Stable Diffusionを使おうと設定した時の手順。

 

PCのセットアップができて、いざStable DiffusionをAUTOMATIC1111版で使えるようにセットアップした時の手順。

 

pip install -U --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu129

 

いろいろ調べていたら、CUDAの新しいバージョンが対応していなかった。

 

ーーー後ほど確認予定

 

 

 

 

まだ、RTX5070での動作は限られていて、下記のVersionでの動作保証はしていた。

Python:3.10

CUDA:Ver12.8

 

下記は自分の環境です。

自分の場合は、Python310 をCドライブへ、Stable DiffusionはDドライブへ格納し設定しました。

C:\Users\xxx\AppData\Local\Programs\Python\Python310 -m venv D:\stable-Diffusion-install\stable-diffusion-webui\venv

D:\stable-Diffusion-install\stable-diffusion-webui\venv

 

 

で、実際にそのバージョンを利用している状態でStable Diffusionを起動しても、下記のエラーが出てしまう。

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がうまく機能していないようだ。

 

 

上記エラーの解消方法

 

1.こちらは、pytorch のバージョンがうまく適用できていないようで、一度、アンインストールをして入れなおした。

pip uninstall torch torchvision torchaudio -y

 

2.念のためキャッシュもクリア

pip cache purge

 

3.★pytorchとその他下記の通り、CUDA12.8用で入れ直し(ここがキモ)

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128

 

4.インストール確認

python -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))"

 

これで、RTX5070 の環境でStable Diffusionが動くようにはなったのだけど、ちょっと古いバージョンになっているので、新たなバージョンでできるよう確認中。

 

この時点でTrueImageでバックアップ取得。

 

 

 

 

 

 

 

-IT/ICT