lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
6.59k stars 643 forks source link

[Bug]: DirectML not launching #58

Open JeSuisSurGithub opened 6 months ago

JeSuisSurGithub commented 6 months ago

Checklist

What happened?

Tried to launch webui through webui-user.bat and it can't. Seems like torch_directml doesn't get installed and that the program supposes that i'm using a cuda compatible gpu.

Steps to reproduce the problem

  1. Git clone stable-diffusion-webui-forge
  2. Add --directml --skip-torch-cuda-test to COMMANDLINE_ARGS in webui-user.bat
  3. Launch webui-user.bat

What should have happened?

It should have launched the UI.

What browsers do you use to access the UI ?

Mozilla Firefox

Sysinfo

I couldn't get the sysinfo dump either

  File "C:\stable-diffusion-webui-forge\launch.py", line 48, in <module>
    main()
  File "C:\stable-diffusion-webui-forge\launch.py", line 29, in main
    filename = launch_utils.dump_sysinfo()
  File "C:\stable-diffusion-webui-forge\modules\launch_utils.py", line 516, in dump_sysinfo
    from modules import sysinfo
  File "C:\stable-diffusion-webui-forge\modules\sysinfo.py", line 12, in <module>
    from modules import paths_internal, timer, shared, extensions, errors
  File "C:\stable-diffusion-webui-forge\modules\shared.py", line 6, in <module>
    from modules import shared_cmd_options, shared_gradio_themes, options, shared_items, sd_models_types
  File "C:\stable-diffusion-webui-forge\modules\sd_models_types.py", line 1, in <module>
    from ldm.models.diffusion.ddpm import LatentDiffusion
ModuleNotFoundError: No module named 'ldm'```

### Console logs

```Shell
venv "C:\stable-diffusion-webui-forge\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: f0.0.7-latest-41-g6aee7a20
Commit hash: 6aee7a20329b4a0e10b87d841d680562bdde65c7
Launching Web UI with arguments: --directml --skip-torch-cuda-test
Traceback (most recent call last):
  File "C:\stable-diffusion-webui-forge\launch.py", line 48, in <module>
    main()
  File "C:\stable-diffusion-webui-forge\launch.py", line 44, in main
    start()
  File "C:\stable-diffusion-webui-forge\modules\launch_utils.py", line 508, in start
    import webui
  File "C:\stable-diffusion-webui-forge\webui.py", line 15, in <module>
    initialize_forge()
  File "C:\stable-diffusion-webui-forge\modules_forge\initialization.py", line 46, in initialize_forge
    import ldm_patched.modules.model_management as model_management
  File "C:\stable-diffusion-webui-forge\ldm_patched\modules\model_management.py", line 38, in <module>
    import torch_directml
ModuleNotFoundError: No module named 'torch_directml'

Additional information

The DirectML fork of a1111 webui works fine on my AMD Ryzen 3500U Vega 8 laptop APU (2x4GB 2400MHz).

SquidPuffer commented 6 months ago

@MythicalChu Add --directml ^.

What is that ^ at the end? Shouldn't it be just --directml or what?

Siralob commented 5 months ago

@SquidPuffer

`Add --directml ^

What is that ^ at the end? Shouldn't it be just --directml or what?

You can use "^" as new line. The below COMMANDLINE_ARGS works for me btw. For example.

set COMMANDLINE_ARGS=--directml ^
  --skip-torch-cuda-test ^
  --always-normal-vram
mlsterpr0 commented 5 months ago

@MythicalChu

comment out all the @torch.inference_mode() (add # before them) on: \ldm_patched\modules\utils.py - line 407 \modules_forge\forge_loader.py - line 236, line 242

change "with torch.inference_mode():" for "with torch.no_grad():" on: \modules\processing.py - line 817

Thanks for this, it kinda works... But the problem is...with my ryzen7735hs and 4gb 680m integrated, it eats all of VRAM and lots of RAM and freezes. So its not working in lowvram mode at all. BTW in standard automatic111 everything works fine in low vram mode. But ppl say forge is faster, so i wanted to give a try... I have another PC with nvidia 1050ti 4gb, and it works perfectly without changing anything, because it manages VRAM very good, i can even watch youtube or whatever, while generating.

JonathanDiez commented 5 months ago

image U know how to help me guys?

SAM-Lik commented 5 months ago

Problem with ryzen 7840HS ( 780M integrated, 8gb allocated).

Error : DML allocator out of memory!

Screen 1 Screen 2 Screen 3 Screen 4

JohnnyX071 commented 4 months ago

For me it says it detected 1024mb cram while i have the RX580 which has 8gb. I suspected that's why it generates images slow too because it doesn't use all of the GPU and is way slower than automatic1111. Any fix for that?

VeteranXT commented 4 months ago

Currently Forge have issue with memory leaks.

kellyling80 commented 4 months ago

@MythicalChu Change checkpoints and VAEs Disabling Japanese language extensions Add --directml ^. Reinstalling webui-forge I have tried all of these and get the same error.

Hmmm what is the cause?

Have tested these settings on a 5500 xt (4GB VRAM, 32GB RAM). Windows allocate a total of 16gb of RAM to vram. Forge just quits stating DML ran out of memory. 1111 on Direct-ML runs pretty flawless.

TvAnimeTOP commented 4 months ago

RuntimeError: Device type privateuseone is not supported for torch.Generator() api. RuntimeError: 'devices' argument must be DML (in cmd) i did all steps but I have this error, I have no idea why

Sounds like you forgot to change seed generation to cpu on the settings, torch.Generator() crashes if it tries that with Directml. This is the config: (it should be the only that shows if you type "cpu" on the search box of the Settings Tab) Random number generator source. (changes seeds drastically; use CPU to produce the same picture across different videocard vendors; use NV to produce same picture as on NVidia videocards) []GPU [o]CPU []NV

still not working now i have TypeError: 'NoneType' object is not iterable

If you switch form SD to SDTurbo or SD to SDXL or SDXL to other..you will get this error. To fix...restart PC. But do not change to other types. You can change 1.5 to 1.5 model however changing models like 1.5 to 2.0 or SDXL or turbo will brick it. So keep that in mind. You are safe to use Loras, But when changing Models makes sure you know what model you are switching. My suggestion same models can be in sub directory as "SD 1.5" that is base model And SDXL for other Like "SD1.5/Dreamshaper.safetensors" is folder is SD1.5...model is dreamshaper. You can orginize better folder and models this way. I hope it helps.

the best part about it i used 1.5 model from the beginning and restarting pc didnt help

edit these files? And did you set Random Number Generator Form GPU to CPU? comment out all the @torch.inference_mode() (add # before them) on: \ldm_patched\modules\utils.py - line 407 \modules_forge\forge_loader.py - line 236, line 242 change "with torch.inference_mode():" for "with torch.no_grad():" on: \modules\processing.py - line 817

its working now ty

Como hiciste bro? el de modificar el primero ese que es utilz.py?No entendi bien

TvAnimeTOP commented 4 months ago

Yes, recent changes broke more things for Directml, I've mentioned them, and a workaround for us, here: #73

That works for ipadapter I was the original op on ipadapter github and still changing that line on every update, how does it help here ? Are there similar lines to change on forge itself ?

Read the rest of my msgs, the last one mentions all the files/lines you need to change. Well, I'll detail them again here anyway... comment out all the @torch.inference_mode() (add # before them) on: \ldm_patched\modules\utils.py - line 407 \modules_forge\forge_loader.py - line 236, line 242 change "with torch.inference_mode():" for "with torch.no_grad():" on: \modules\processing.py - line 817 This fixes normal execution and Tiled Vae Decoding for us. I'm running it with similar performance I get on ComfyUI, which is the fastest It has worked on my rx580 8Gb (windows), despite it saying "low_vram mode" here.

HOLY ... Just changed all those files, and regarding tiled-vae , yes after using it on my workflows no more out of memory again even on sdxl.

Edit : Yes sd1.5 and sdxl working, tiled-vae auto enabling and working also. But the speed seems identical to comfyui and fooocus.

Edit 2: Talked too early, sd1.5 models and sdxl turbo worked, when I tried a standard sdxl (juggernaught8) none type error came back again. If I restart PC , I can load and use full sdxl models without error, only if I change from sd1.5 or sdxl turbo to sdxl none... error returns and persists until pc restarts.

Ayudame porfa bro yo no puedo ya modifique hice lo del tutorial que deja el vago pero igual me dice TypeError: 'NoneType' object is not iterable