lshqqytiger / stable-diffusion-webui-amdgpu

Stable Diffusion web UI
GNU Affero General Public License v3.0
1.8k stars 186 forks source link

[Bug]: OSError: pdh.dll: cannot open shared object file on WSL #232

Closed meseaw closed 1 year ago

meseaw commented 1 year ago

Is there an existing issue for this?

What happened?

I updated my local branch from commit 4873e6aaba62c2fa2e4481798e85098e50e1e2c6 to commit b180d1df30125ed606f94a779536f2dfb8aca74a, and then I found an error about pdh.dll when I launch webui.sh. It seems that this commit can only run on win platform, but my environment is WSL2 of win11. I'm sure I can launch webui before I update. So does it mean subsequent commits will not work on wsl too?

Steps to reproduce the problem

  1. git pull
  2. launch webui.sh
  3. the error occurs

What should have happened?

The webui should be launched

Version or Commit where the problem happens

b180d1df30125ed606f94a779536f2dfb8aca74a

What Python version are you running on ?

Python 3.10.x

What platforms do you use to access the UI ?

Linux

What device are you running WebUI on?

AMD iGPUs

Cross attention optimization

InvokeAI

What browsers do you use to access the UI ?

Microsoft Edge

Command Line Arguments

./webui.sh --opt-sub-quad-attention --lowvram --precision full --no-half --no-half-vae --opt-split-attention-invokeai --disable-nan-check --always-batch-cond-uncond --sub-quad-q-chunk-size 512 --sub-quad-kv-chunk-size 512 --sub-quad-chunk-threshold 80 --upcast-sampling

List of extensions

a1111-sd-webui-lycoris adetailer sd-webui-additional-networks

Console logs

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on meseaw user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
fatal: 没有发现名称,无法描述任何东西。
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0]
Version: 1.5.1
Commit hash: b180d1df30125ed606f94a779536f2dfb8aca74a

Launching Web UI with arguments: --opt-sub-quad-attention --lowvram --precision full --no-half --no-half-vae --opt-split-attention-invokeai --disable-nan-check --always-batch-cond-uncond --sub-quad-q-chunk-size 512 --sub-quad-kv-chunk-size 512 --sub-quad-chunk-threshold 80 --upcast-sampling
no module 'xformers'. Processing without...
no module 'xformers'. Processing without...
No module 'xformers'. Proceeding without it.
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/meseaw/stable-diffusion-webui-directml/launch.py:39 in <module>                            │
│                                                                                                  │
│   36                                                                                             │
│   37                                                                                             │
│   38 if __name__ == "__main__":                                                                  │
│ ❱ 39 │   main()                                                                                  │
│   40                                                                                             │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/launch.py:35 in main                                │
│                                                                                                  │
│   32 │   if args.test_server:                                                                    │
│   33 │   │   configure_for_tests()                                                               │
│   34 │                                                                                           │
│ ❱ 35 │   start()                                                                                 │
│   36                                                                                             │
│   37                                                                                             │
│   38 if __name__ == "__main__":                                                                  │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/launch_utils.py:443 in start                │
│                                                                                                  │
│   440                                                                                            │
│   441 def start():                                                                               │
│   442 │   print(f"Launching {'API server' if '--nowebui' in sys.argv else 'Web UI'} with argum   │
│ ❱ 443 │   import webui                                                                           │
│   444 │   if '--nowebui' in sys.argv:                                                            │
│   445 │   │   webui.api_only()                                                                   │
│   446 │   else:                                                                                  │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/webui.py:54 in <module>                             │
│                                                                                                  │
│    51 startup_timer.record("import ldm")                                                         │
│    52                                                                                            │
│    53 from modules import extra_networks                                                         │
│ ❱  54 from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, queue_lock  # noq   │
│    55                                                                                            │
│    56 # Truncate version number of nightly/local build of PyTorch to not cause exceptions with   │
│    57 if ".dev" in torch.__version__ or "+git" in torch.__version__:                             │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/call_queue.py:6 in <module>                 │
│                                                                                                  │
│     3 import threading                                                                           │
│     4 import time                                                                                │
│     5                                                                                            │
│ ❱   6 from modules import shared, progress, errors                                               │
│     7                                                                                            │
│     8 queue_lock = threading.Lock()                                                              │
│     9                                                                                            │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/shared.py:72 in <module>                    │
│                                                                                                  │
│    69 if cmd_opts.olive:                                                                         │
│    70 │   cmd_opts.onnx = True                                                                   │
│    71 if cmd_opts.backend == "directml":                                                         │
│ ❱  72 │   directml_init()                                                                        │
│    73                                                                                            │
│    74                                                                                            │
│    75 devices.device, devices.device_interrogate, devices.device_gfpgan, devices.device_esrgan   │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/dml/__init__.py:38 in directml_init         │
│                                                                                                  │
│   35 │   torch.cuda.mem_get_info = torch.dml.mem_get_info                                        │
│   36                                                                                             │
│   37 def directml_init():                                                                        │
│ ❱ 38 │   from modules.dml.backend import DirectML # pylint: disable=ungrouped-imports            │
│   39 │   # Alternative of torch.cuda for DirectML.                                               │
│   40 │   torch.dml = DirectML                                                                    │
│   41                                                                                             │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/dml/backend.py:10 in <module>               │
│                                                                                                  │
│    7 from .utils import rDevice, get_device                                                      │
│    8 from .device import device                                                                  │
│    9 from .device_properties import DeviceProperties                                             │
│ ❱ 10 from .memory import MemoryProvider                                                          │
│   11                                                                                             │
│   12 def amd_mem_get_info(device: Optional[rDevice]=None) -> tuple[int, int]:                    │
│   13 │   from .memory_amd import AMDMemoryProvider                                               │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/dml/memory.py:4 in <module>                 │
│                                                                                                  │
│    1 from os import getpid                                                                       │
│    2 from collections import defaultdict                                                         │
│    3                                                                                             │
│ ❱  4 from modules.dml.pdh import HQuery, HCounter, expand_wildcard_path                          │
│    5                                                                                             │
│    6 class MemoryProvider:                                                                       │
│    7 │   hQuery: HQuery                                                                          │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/dml/pdh/__init__.py:5 in <module>           │
│                                                                                                  │
│    2 from ctypes.wintypes import *                                                               │
│    3 from typing import NamedTuple, TypeVar                                                      │
│    4                                                                                             │
│ ❱  5 from .apis import PdhExpandWildCardPathW, PdhOpenQueryW, PdhAddEnglishCounterW, PdhColle    │
│    6 from .structures import PDH_HQUERY, PDH_HCOUNTER, PDH_FMT_COUNTERVALUE, PPDH_FMT_COUNTER    │
│    7 from .defines import *                                                                      │
│    8 from .msvcrt import malloc                                                                  │
│                                                                                                  │
│ /home/meseaw/stable-diffusion-webui-directml/modules/dml/pdh/apis.py:8 in <module>               │
│                                                                                                  │
│    5 from .structures import *                                                                   │
│    6 from .defines import *                                                                      │
│    7                                                                                             │
│ ❱  8 pdh = CDLL("pdh.dll")                                                                       │
│    9                                                                                             │
│   10 PdhExpandWildCardPathW: Callable = pdh.PdhExpandWildCardPathW                               │
│   11 PdhExpandWildCardPathW.restype = PDH_FUNCTION                                               │
│                                                                                                  │
│ /home/meseaw/anaconda3/envs/py310/lib/python3.10/ctypes/__init__.py:374 in __init__              │
│                                                                                                  │
│   371 │   │   self._FuncPtr = _FuncPtr                                                           │
│   372 │   │                                                                                      │
│   373 │   │   if handle is None:                                                                 │
│ ❱ 374 │   │   │   self._handle = _dlopen(self._name, mode)                                       │
│   375 │   │   else:                                                                              │
│   376 │   │   │   self._handle = handle                                                          │
│   377                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: pdh.dll: cannot open shared object file: No such file or directory

Additional information

No response

lshqqytiger commented 1 year ago

You can't select Performance Counter on WSL WebUI. Find directml_memory_provider from config.json and change the value to None or atiadlxx (AMD only).

meseaw commented 1 year ago

I didn't find directml_memory_provider in config.json, so I added it like this: "directml_memory_provider": "None" But it still doesn't work. Did I go wrong somewhere?

meseaw commented 1 year ago

I update to commit 58b9fb5f1db36ea8335b7553b5391e4ec1e53393 and then this problem has been solved. Thanks!