Stable Diffusionをubuntu 22.04でCPUのみで試しました
1.概要
Stable DiffusionはGPU必須となっていますが、CPUだけでも実行できるとの記事を見つけて試してみました。確かにインストールはできますが、実行すると速度が遅いだけのようです。GPU版を知っているとCPU版では満足できない速度かも知れません。その内容を記述します。
2.詳細
GPU版と同じ環境を利用しました。セットアップ方法の差でCPU版になります。
環境は以下のとおりです
cpu core i3-7100
memory 16GB
SSD 250GB
手順は以下のとおりです。参考資料に沿って実行します。
(a) Stable Diffusionのインストールと起動
(b) GUI利用
(a) Stable Diffusionのインストールと起動
準備として下記モジュールをインストールします
$ sudo apt-get -y install git
$ sudo apt -y install python3-pip python3-venv python3-packaging
$ git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
$ cd ~/stable-diffusion-webui
$ python3 launch.py --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate --precision full --no-half
何故かstable-diffusion-webui/launch.pyでエラーになります。
Traceback (most recent call last):
File "/home/nakasima/stable-diffusion-webui/launch.py", line 48, in <module>
main()
File "/home/nakasima/stable-diffusion-webui/launch.py", line 44, in main
start()
File "/home/nakasima/stable-diffusion-webui/modules/launch_utils.py", line 465, in start
import webui
File "/home/nakasima/stable-diffusion-webui/webui.py", line 13, in <module>
initialize.imports()
File "/home/nakasima/stable-diffusion-webui/modules/initialize.py", line 15, in imports
import torch # noqa: F401
ModuleNotFoundError: No module named 'torch'
下記コマンドを再実行しました
$ python3 launch.py --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate --precision full --no-half
ダウンロードが実行されて、起動します。
(d) GUI利用
Running on local URL: http://0.0.0.0:7860
の表示が出ているので、ブラウザ(Firefox)から
http://localhost:7860/
でGUIに接続します。
参考
[外部サイト参照]
・Stable Diffusion Web UIをグラボなしCPUのみで使う方法
コメント
コメントを投稿