6
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?

More than 1 year has passed since last update.

Stable Diffusionの実行環境をpyenv-virtualenvで作る

Posted at

概要

Stable Diffusion手元のPCで実行してみました。
公式手順ではAnacondaを使いますが、pyenv-virtualenvで動かしてみました。

方法

git clone https://github.com/CompVis/stable-diffusion
cd stable-diffusion
vi requirements.txt

requrements.txtには、environment.yamlのpipの項目からコピーしたものを記入して、この場所に置きます。

requirements.txt
albumentations==0.4.3
diffusers
opencv-python==4.1.2.30
pudb==2019.2
invisible-watermark
imageio==2.9.0
imageio-ffmpeg==0.4.2
pytorch-lightning==1.4.2
omegaconf==2.1.1
test-tube>=0.7.5
streamlit>=0.73.1
einops==0.3.0
torch-fidelity==0.3.0
transformers==4.19.2
torchmetrics==0.6.0
kornia==0.6
-e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers
-e git+https://github.com/openai/CLIP.git@main#egg=clip
-e .

重みファイル sd-v1-4.ckpt を https://huggingface.co/CompVis/stable-diffusion-v-1-4-original からダウンロードしてこの場所に置きます。

pyenv install 3.8.5
pyenv virtualenv 3.8.5 ldm
pyenv local ldm

PyTorchをインストールします。Ubuntu 22.04で、CUDAはsudo apt install nvidia-cuda-toolkitで入れたものとします。

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
pip install -r requirements.txt

実行します。

python scripts/txt2img.py --prompt "engineer" --plms --ckpt sd-v1-4.ckpt --n_samples 1

実行時間は50秒くらいでした。

参考URL

以下のURLを参考にさせていただきました。
https://zenn.dev/ettsu/articles/6a1e68cea8864b

6
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
6
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?