2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuでStable Diffusionにより画像生成

Posted at

PCのスペック

  • nividia-smi でGPU情報確認
    グラフィックボードの基本情報:

    GPU: NVIDIA GeForce RTX 4090
    Driver Version: 535.183.01 (NVIDIAのドライババージョン)
    CUDA Version: 12.2 (CUDA Toolkitのバージョン。GPUを使った並列計算に必要なソフトウェア)
    Bus-Id: 00000000:01:00.0 (PCI Expressバス上のGPUの位置)

Stable Diffusion の環境構築

Stable Diffusion Web UIのgithub を参考にします
dependency を確認します

1 何系かを調べます

cat /etc/os-release によってdebianであることがわかります

2 pythonのversion

推奨は、3.10.6なのでcondaによって環境を作成します。
conda create -n stable_diffusion_webui python=3.10.6 により仮想環境を作成します。
conda activate stable_diffusion_webui により仮想環境に入ります。

3 git clone

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git によりwebuiをinstallします。

StableDiffusion実行

1. webUI立ち上げ

bash webui.sh を実行します。
(このときにエラーが出る場合は、GPUのVersion、CUDAのVersionと仮想環境のPythonのVersionを確認してください)

しばらく待つと、 http://127.0.0.1:7860/ にWebUIが表示されます。

2. Stable Diffusion のcheckpointを変更

既存のモデルでは、作成したい画像が手に入らない場合はcheckpointを変更します。
civitai に大量にmodelがあるので好みのモデルを探してダウンロードします。
(詳細なその他の設定やできることは wiki に記載があります)

stable-diffusion-webui/models/Stable-diffusion/ にcheckpointを配置します。

3. 画像生成

txt2imgで画像を生成する手順の詳細は他のqiitaを閲覧ください。
画像保存ボタンが存在していますが、 outputs/txt2img-images/ に画像が保存されます。

まとめ

Stable Diffusionを UbnutuのPCで環境構築、画像生成を行いました。

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?