私的AI研究会 > Diffusion > Diffusion_ov
高性能画像生成AI「Stable Diffusion」を検証する
NVIDIA GPU 未搭載で Intel® CPU / Intel® GPU 搭載機種へのインストール手順
(base) conda create -n StableDiffusion python=3.10.6 -y
(base) conda activate StableDiffusion (StableDiffusion) conda env list
(base) cd /anaconda_win/workspace_3
(StableDiffusion) git clone https://github.com/openvinotoolkit/stable-diffusion-webui.git (StableDiffusion) cd stable-diffusion-webui
(StableDiffusion) ./webui-user.bat
(StableDiffusion) PS C:\anaconda_win\workspace_3\stable-diffusion-webui> ./webui-user.bat Creating venv in directory C:\anaconda_win\workspace_3\stable-diffusion-webui\venv using python "C:\Users\izuts\anaconda3\envs\StableDiffusion\python.exe" venv "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\Scripts\Python.exe" fatal: No names found, cannot describe anything. : Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors *** Error loading script: openvino_accelerate.py Traceback (most recent call last): File "C:\anaconda_win\workspace_3\stable-diffusion-webui\modules\scripts.py", line 382, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "C:\anaconda_win\workspace_3\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:\anaconda_win\workspace_3\stable-diffusion-webui\scripts\openvino_accelerate.py", line 47, in <module> from diffusers import ( File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\__init__.py", line 5, in <module> from .utils import ( File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\utils\__init__.py", line 38, in <module> from .dynamic_modules_utils import get_class_from_dynamic_module File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\utils\dynamic_modules_utils.py", line 28, in <module> from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info ImportError: cannot import name 'cached_download' from 'huggingface_hub' (C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\__init__.py) :・「v1-5-pruned-emaonly.safetensors」ダウンロード途中で停止して動かない場合は 'Ctrl' + 'c' で強制終了(Webページが開くので閉じる)
"https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors"・ダウンロードしたファイルを配置
"C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors"
(StableDiffusion) PS C:\anaconda_win\workspace_3\stable-diffusion-webui> ./webui-user.bat venv "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\Scripts\Python.exe" fatal: No names found, cannot describe anything. : Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled *** Error loading script: openvino_accelerate.py Traceback (most recent call last): File "C:\anaconda_win\workspace_3\stable-diffusion-webui\modules\scripts.py", line 382, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "C:\anaconda_win\workspace_3\stable-diffusion-webui\modules\script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "C:\anaconda_win\workspace_3\stable-diffusion-webui\scripts\openvino_accelerate.py", line 47, in <module> from diffusers import ( File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\__init__.py", line 5, in <module> from .utils import ( File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\utils\__init__.py", line 38, in <module> from .dynamic_modules_utils import get_class_from_dynamic_module File "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\utils\dynamic_modules_utils.py", line 28, in <module> from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info ImportError: cannot import name 'cached_download' from 'huggingface_hub' (C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\__init__.py) :・下記のファイルをエディタで修正
"C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\lib\site-packages\diffusers\utils\dynamic_modules_utils.py"28行目をコメントアウト
: 25: from typing import Dict, Optional, Union 26: from urllib import request 27: 28: #from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info 29: from packaging import version 30: 31: from .. import __version__ :
(StableDiffusion) PS C:\anaconda_win\workspace_3\stable-diffusion-webui> ./webui-user.bat venv "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\Scripts\Python.exe" fatal: No names found, cannot describe anything. Python 3.10.6 | packaged by conda-forge | (main, Oct 24 2022, 16:02:16) [MSC v.1916 64 bit (AMD64)] Version: 1.6.0 Commit hash: e5a634da06c62d72dbdc764b16c65ef3408aa588 Launching Web UI with arguments: --skip-torch-cuda-test --precision full --no-half no module 'xformers'. Processing without... no module 'xformers'. Processing without... No module 'xformers'. Proceeding without it. Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled Loading weights [6ce0161689] from C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors Creating model from config: C:\anaconda_win\workspace_3\stable-diffusion-webui\configs\v1-inference.yaml Running on local URL: http://127.0.0.1:7860
set COMMANDLINE_ARGS=--skip-torch-cuda-test --precision full --no-half --theme=dark
$name = @" *** Stable Diffusion environment (OpenVINO) *** "@ Write-Host $name conda activate StableDiffusion Set-Location '/anaconda_win/workspace_3/stable-diffusion-webui' ./webui-user.bat
(base) conda create -n StableDiffusion python=3.10.6 -y
(base) conda activate StableDiffusion (StableDiffusion) conda env list
(base) cd ~/workspace_3
(StableDiffusion) git clone https://github.com/openvinotoolkit/stable-diffusion-webui.git (StableDiffusion) cd stable-diffusion-webui
(StableDiffusion) export PYTORCH_TRACING_MODE=TORCHFX (StableDiffusion) export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half"
(StableDiffusion) ./webui.sh
(StableDiffusion) XXXXX@ubuntu-lat:~/workspace_3/stable-diffusion-webui$ ./webui.sh ################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################ : *** Error loading script: openvino_accelerate.py Traceback (most recent call last): File "/home/XXXXX/workspace_3/stable-diffusion-webui/modules/scripts.py", line 382, in load_scripts script_module = script_loading.load_module(scriptfile.path) File "/home/XXXXX/workspace_3/stable-diffusion-webui/modules/script_loading.py", line 10, in load_module module_spec.loader.exec_module(module) File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/XXXXX/workspace_3/stable-diffusion-webui/scripts/openvino_accelerate.py", line 47, in <module> from diffusers import ( File "/home/XXXXX/workspace_3/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/__init__.py", line 5, in <module> from .utils import ( File "/home/XXXXX/workspace_3/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/utils/__init__.py", line 38, in <module> from .dynamic_modules_utils import get_class_from_dynamic_module File "/home/XXXXX/workspace_3/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/utils/dynamic_modules_utils.py", line 28, in <module> from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info ImportError: cannot import name 'cached_download' from 'huggingface_hub' (/home/XXXXX/workspace_3/stable-diffusion-webui/venv/lib/python3.10/site-packages/huggingface_hub/__init__.py) :・ブラウザを閉じ、ターミナル上で 'Ctrl' + 'c' を押して終了する
"~/workspace_3/stable-diffusion-webui/venv/lib/python3.10/site-packages/diffusers/utils/dynamic_modules_utils.py"28行目をコメントアウト
: 25: from typing import Dict, Optional, Union 26: from urllib import request 27: 28: #from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info 29: from packaging import version 30: 31: from .. import __version__ :
(StableDiffusion) $ pip install --upgrade pip・「venv」仮想環境をアクティブにする
(StableDiffusion) $ . venv/bin/activate・「pytorch」をアップデートする
(venv) (StableDiffusion) $ pip install torch==2.1.0
1: #!/bin/bash 2: ######################################################### 3: # Uncomment and change the variables below to your need:# 4: ######################################################### 5: 6: # Install directory without trailing slash 7: #install_dir="/home/$(whoami)" 8: 9: # Name of the subdirectory 10: #clone_dir="stable-diffusion-webui" 11: 12: # Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention" 13: export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half --theme=dark" :
#!/bin/sh echo "*** (StableDiffusion OpenVINO) environment ***" cd $HOME/workspace_3/stable-diffusion-webui conda activate StableDiffusion ./webui.sh
(StableDiffusion) cd /anaconda_win/workspace_3/stable-diffusion-webui (StableDiffusion) webui-user.batLinux の場合
(StableDiffusion) cd ~/workspace_3/stable-diffusion-webui (StableDiffusion) ./webui.sh
(StableDiffusion) PS C:\anaconda_win\workspace_3\stable-diffusion-webui> ./webui-user.bat venv "C:\anaconda_win\workspace_3\stable-diffusion-webui\venv\Scripts\Python.exe" fatal: No names found, cannot describe anything. Python 3.10.6 | packaged by conda-forge | (main, Oct 24 2022, 16:02:16) [MSC v.1916 64 bit (AMD64)] Version: 1.6.0 Commit hash: e5a634da06c62d72dbdc764b16c65ef3408aa588 Launching Web UI with arguments: --skip-torch-cuda-test --precision full --no-half no module 'xformers'. Processing without... no module 'xformers'. Processing without... No module 'xformers'. Proceeding without it. Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled Loading weights [6ce0161689] from C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors Creating model from config: C:\anaconda_win\workspace_3\stable-diffusion-webui\configs\v1-inference.yaml Running on local URL: http://127.0.0.1:7860 To create a public link, set `share=True` in `launch()`. Startup time: 8.9s (prepare environment: 0.3s, import torch: 3.9s, import gradio: 0.9s, setup paths: 0.7s, initialize shared: 0.1s, other imports: 0.6s, setup codeformer: 0.1s, load scripts: 1.2s, create ui: 0.8s, gradio launch: 0.3s). Applying attention optimization: InvokeAI... done. Model loaded in 3.1s (load weights from disk: 0.9s, create model: 0.4s, apply weights to model: 1.7s). {} Loading weights [6ce0161689] from C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors OpenVINO Script: created model from config : C:\anaconda_win\workspace_3\stable-diffusion-webui\configs\v1-inference.yaml 100%|███████████████████████████████████████████████| 20/20 [01:03<00:00, 3.18s/it] {} 100%|███████████████████████████████████████████████| 20/20 [00:20<00:00, 1.05s/it] {} 100%|███████████████████████████████████████████████| 20/20 [00:21<00:00, 1.07s/it] :・DELL Latitude 7520 (Ubuntu20.04) ログ
(StableDiffusion) mizutu@ubuntu-lat:~/workspace_3/stable-diffusion-webui$ ./webui.sh ################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################ ################################################################ Running on mizutu user ################################################################ ################################################################ Repo already cloned, using it as install directory ################################################################ ################################################################ Create and activate python venv ################################################################ ################################################################ Launching launch.py... ################################################################ Cannot locate TCMalloc (improves CPU memory usage) fatal: No names found, cannot describe anything. Python 3.10.6 (main, Oct 24 2022, 16:07:47) [GCC 11.2.0] Version: 1.6.0 Commit hash: e5a634da06c62d72dbdc764b16c65ef3408aa588 Launching Web UI with arguments: --skip-torch-cuda-test --precision full --no-half --theme=dark no module 'xformers'. Processing without... no module 'xformers'. Processing without... No module 'xformers'. Proceeding without it. Warning: caught exception 'Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx', memory monitor disabled Loading weights [6ce0161689] from /home/mizutu/workspace_3/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors Running on local URL: http://127.0.0.1:7860 To create a public link, set `share=True` in `launch()`. Creating model from config: /home/mizutu/workspace_3/stable-diffusion-webui/configs/v1-inference.yaml Startup time: 6.5s (import torch: 2.8s, import gradio: 0.6s, setup paths: 0.5s, other imports: 0.4s, load scripts: 0.9s, create ui: 0.7s, gradio launch: 0.4s). Applying attention optimization: InvokeAI... done. Model loaded in 2.9s (load weights from disk: 1.0s, create model: 0.5s, apply weights to model: 1.3s, calculate empty prompt: 0.1s). {} Loading weights [6ce0161689] from /home/mizutu/workspace_3/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors OpenVINO Script: created model from config : /home/mizutu/workspace_3/stable-diffusion-webui/configs/v1-inference.yaml 100%|███████████████████████████████████████████████| 20/20 [01:11<00:00, 3.57s/it] {} 100%|███████████████████████████████████████████████| 20/20 [00:29<00:00, 1.47s/it] {} 100%|███████████████████████████████████████████████| 20/20 [00:29<00:00, 1.48s/it]
(StableDiffusion) git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git stable-diffusion-webui_cpu (StableDiffusion) cd stable-diffusion-webui_cpu「webui-user.bat」の COMMANDLINE_ARGS の行を修正
1: @echo off 2: 3: set PYTHON= 4: set GIT= 5: set VENV_DIR= 6: set COMMANDLINE_ARGS=--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate --precision full --no-half 7: 8: call webui.bat
rd C:\anaconda_win\workspace_3\stable-diffusion-webui_cpu\models\Stable-diffusion mklink /d "C:\anaconda_win\workspace_3\stable-diffusion-webui_cpu\models\Stable-diffusion" "C:\anaconda_win\workspace_3\stable-diffusion-webui\models\Stable-diffusion"ControlNet モデル
rd C:\anaconda_win\workspace_3\stable-diffusion-webui_cpu\models\ControlNet mklink /d "C:\anaconda_win\workspace_3\stable-diffusion-webui_cpu\models\ControlNet" "C:\anaconda_win\workspace_3\stable-diffusion-webui\models\ControlNet"
cd ~/workspace_3/stable-diffusion-webui_cpu/models ln -s ~/workspace_3/stable-diffusion-webui/models/Stable-diffusion Stable-diffusionControlNet モデル
cd ~/workspace_3/stable-diffusion-webui_cpu/models ln -s ~/workspace_3/stable-diffusion-webui/models/ControlNet ControlNet
cd ./extensions git clone https://github.com/Mikubill/sd-webui-controlnet・「ControlNet OpenPose Editer」
cd ./extensions git clone https://github.com/fkunn1326/OpenPose-editor.git
: Set torch._dynamo.config.verbose=True for more information You can suppress this exception and fall back to eager by setting: torch._dynamo.config.suppress_errors = True
(StableDiffusion) $ . venv/Scripts/activate (venv) (StableDiffusion) $ pip install torch==2.1.0Linux
(StableDiffusion) $ . venv/bin/activate (venv) (StableDiffusion) $ pip install torch==2.1.0
*** Error completing request████████████████████████████████████████| 45/45 [05:09<00:00, 6.64s/it] *** Arguments: ('task(2jgvswlne7f50ml)', '(masterpiece,best quality:1.4),(8k,raw photo,photo realistic:1.2)... : AttributeError: 'ImageDraw' object has no attribute 'multiline_textsize'
Cannot locate TCMalloc. Do you have tcmalloc or google-perftool installed on your system? (improves CPU memory usage)