vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.54k stars 408 forks source link

[ISSUE]: Unable to launch SD.Next due to Missing Module from Torch #3360

Closed MetaverseRPN closed 1 month ago

MetaverseRPN commented 2 months ago

Issue Description

Upon attempting to launch SD.NEXT on Windows 11, it errors out with WinError 126, specified Module could not be found. This appears to be related to this ongoing issue on https://github.com/pytorch/pytorch/issues/131662 which does provide a workaround with manually installing pytorch nightly, however this seems to break xformers as it does not get compiled with CUDA support. I have an NVIDIA GeForce RTX 4070 Ti, so it should work with CUDA. So I am not sure how best to resolve this on my end. Any assistance in applying this workaround or getting this fixed permanently would be greatly appreciated

Version Platform Description

Starting SD.Next 11:32:00-385827 INFO Logger: file="E:\AI\SDNext\sdnext.log" level=DEBUG size=65 mode=create 11:32:00-386831 INFO Python version=3.10.11 platform=Windows bin="E:\AI\SDNext\venv\Scripts\python.exe" venv="E:\AI\SDNext\venv" 11:32:01-006892 INFO Version: app=sd.next updated=2024-07-24 hash=a874b27e branch=master url=https://github.com/vladmandic/automatic.git/tree/master ui=main 11:32:11-633080 INFO Platform: arch=AMD64 cpu=AMD64 Family 25 Model 97 Stepping 2, AuthenticAMD system=Windows release=Windows-10-10.0.22631-SP0 python=3.10.11 11:32:11-634080 DEBUG Setting environment tuning 11:32:11-644132 INFO HF cache folder: C:\Users\nicho.cache\huggingface\hub 11:32:11-645133 DEBUG Torch allocator: "garbage_collection_threshold:0.80,max_split_size_mb:512" 11:32:11-645133 DEBUG Torch overrides: cuda=False rocm=False ipex=False diml=False openvino=False 11:32:11-646132 DEBUG Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True 11:32:11-647132 INFO nVidia CUDA toolkit detected: nvidia-smi present 11:32:11-648133 INFO Install: package="onnxruntime-gpu" mode=pip 11:32:11-648133 DEBUG Running: pip="install --upgrade onnxruntime-gpu" 11:32:14-885793 INFO Install: package="torch torchvision --index-url https://download.pytorch.org/whl/cu121" mode=pip 11:32:14-886793 DEBUG Running: pip="install --upgrade torch torchvision --index-url https://download.pytorch.org/whl/cu121" 11:33:41-357069 INFO Install: package="--pre xformers" mode=pip 11:33:41-358068 DEBUG Running: pip="install --upgrade --no-deps --pre xformers" 11:34:32-175122 DEBUG Cannot install xformers package: [WinError 126] The specified module could not be found. Error loading "E:\AI\SDNext\venv\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies. 11:34:32-334228 INFO Forcing reinstall of all packages 11:34:32-386921 INFO Verifying requirements 11:34:32-390429 INFO Verifying packages 11:34:32-391429 INFO Install: package="git+https://github.com/openai/CLIP.git" mode=pip 11:34:32-392430 DEBUG Running: pip="install --upgrade git+https://github.com/ope

Relevant log output

.\webui.bat --debug --use-xformers --medvram --reinstall
Using VENV: E:\AI\SDNext\venv
11:32:00-382828 INFO     Starting SD.Next
11:32:00-385827 INFO     Logger: file="E:\AI\SDNext\sdnext.log" level=DEBUG size=65 mode=create
11:32:00-386831 INFO     Python version=3.10.11 platform=Windows bin="E:\AI\SDNext\venv\Scripts\python.exe"
                         venv="E:\AI\SDNext\venv"
11:32:01-006892 INFO     Version: app=sd.next updated=2024-07-24 hash=a874b27e branch=master
                         url=https://github.com/vladmandic/automatic.git/tree/master ui=main
11:32:11-633080 INFO     Platform: arch=AMD64 cpu=AMD64 Family 25 Model 97 Stepping 2, AuthenticAMD system=Windows
                         release=Windows-10-10.0.22631-SP0 python=3.10.11
11:32:11-634080 DEBUG    Setting environment tuning
11:32:11-644132 INFO     HF cache folder: C:\Users\nicho\.cache\huggingface\hub
11:32:11-645133 DEBUG    Torch allocator: "garbage_collection_threshold:0.80,max_split_size_mb:512"
11:32:11-645133 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False openvino=False
11:32:11-646132 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True
11:32:11-647132 INFO     nVidia CUDA toolkit detected: nvidia-smi present
11:32:11-648133 INFO     Install: package="onnxruntime-gpu" mode=pip
11:32:11-648133 DEBUG    Running: pip="install --upgrade onnxruntime-gpu"
11:32:14-885793 INFO     Install: package="torch torchvision --index-url https://download.pytorch.org/whl/cu121"
                         mode=pip
11:32:14-886793 DEBUG    Running: pip="install --upgrade torch torchvision --index-url
                         https://download.pytorch.org/whl/cu121"
11:33:41-357069 INFO     Install: package="--pre xformers" mode=pip
11:33:41-358068 DEBUG    Running: pip="install --upgrade --no-deps --pre xformers"
11:34:32-175122 DEBUG    Cannot install xformers package: [WinError 126] The specified module could not be found. Error
                         loading "E:\AI\SDNext\venv\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.
11:34:32-334228 INFO     Forcing reinstall of all packages
11:34:32-386921 INFO     Verifying requirements
11:34:32-390429 INFO     Verifying packages
11:34:32-391429 INFO     Install: package="git+https://github.com/openai/CLIP.git" mode=pip
11:34:32-392430 DEBUG    Running: pip="install --upgrade git+https://github.com/openai/CLIP.git"
11:35:07-210373 INFO     Startup: standard
11:35:07-211372 INFO     Verifying submodules
11:35:10-972058 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main
11:35:11-153607 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main
11:35:11-328875 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main
11:35:11-586686 DEBUG    Git detached head detected: folder="extensions-builtin/sdnext-modernui" reattach=main
11:35:11-587685 DEBUG    Submodule: extensions-builtin/sdnext-modernui / main
11:35:11-843439 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master
11:35:12-020658 DEBUG    Submodule: modules/k-diffusion / master
11:35:12-281429 DEBUG    Git detached head detected: folder="wiki" reattach=master
11:35:12-282427 DEBUG    Submodule: wiki / master
11:35:12-607745 DEBUG    Register paths
11:35:12-649899 DEBUG    Installed packages: 189
11:35:12-651910 DEBUG    Extensions all: ['Lora', 'sd-extension-chainner', 'sd-extension-system-info',
                         'sd-webui-agent-scheduler', 'sdnext-modernui', 'stable-diffusion-webui-rembg']
11:35:12-762376 DEBUG    Running extension installer:
                         E:\AI\SDNext\extensions-builtin\sd-webui-agent-scheduler\install.py
11:35:13-056651 DEBUG    Running extension installer:
                         E:\AI\SDNext\extensions-builtin\stable-diffusion-webui-rembg\install.py
11:35:13-332470 DEBUG    Extensions all: ['adetailer']
11:35:13-334470 DEBUG    Running extension installer: E:\AI\SDNext\extensions\adetailer\install.py
11:35:13-599057 INFO     Extensions enabled: ['Lora', 'sd-extension-chainner', 'sd-extension-system-info',
                         'sd-webui-agent-scheduler', 'sdnext-modernui', 'stable-diffusion-webui-rembg', 'adetailer']
11:35:13-600057 INFO     Verifying requirements
11:35:13-600561 DEBUG    Setup complete without errors: 1722872114
11:35:13-605565 DEBUG    Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}
11:35:13-606565 DEBUG    Starting module: <module 'webui' from 'E:\\AI\\SDNext\\webui.py'>
11:35:13-607564 INFO     Command line args: ['--debug', '--use-xformers', '--medvram', '--reinstall'] medvram=True
                         use_xformers=True reinstall=True debug=True
11:35:13-608564 DEBUG    Env flags: []
╭───────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────╮
│ E:\AI\SDNext\launch.py:265 in <module>                                                                               │
│                                                                                                                      │
│   264 if __name__ == "__main__":                                                                                     │
│ ❱ 265     main()                                                                                                     │
│   266                                                                                                                │
│                                                                                                                      │
│ E:\AI\SDNext\launch.py:242 in main                                                                                   │
│                                                                                                                      │
│   241                                                                                                                │
│ ❱ 242     uv, instance = start_server(immediate=True, server=None)                                                   │
│   243     while True:                                                                                                │
│                                                                                                                      │
│ E:\AI\SDNext\launch.py:168 in start_server                                                                           │
│                                                                                                                      │
│   167     get_custom_args()                                                                                          │
│ ❱ 168     module_spec.loader.exec_module(server)                                                                     │
│   169     uvicorn = None                                                                                             │
│ in exec_module:883                                                                                                   │
│ in _call_with_frames_removed:241                                                                                     │
│                                                                                                                      │
│ E:\AI\SDNext\webui.py:11 in <module>                                                                                 │
│                                                                                                                      │
│    10 from threading import Thread                                                                                   │
│ ❱  11 import modules.loader                                                                                          │
│    12 import torch # pylint: disable=wrong-import-order                                                              │
│                                                                                                                      │
│ E:\AI\SDNext\modules\loader.py:14 in <module>                                                                        │
│                                                                                                                      │
│   13                                                                                                                 │
│ ❱ 14 import torch # pylint: disable=C0411                                                                            │
│   15 try:                                                                                                            │
│                                                                                                                      │
│ E:\AI\SDNext\venv\lib\site-packages\torch\__init__.py:148 in <module>                                                │
│                                                                                                                      │
│    147                 err.strerror += f' Error loading "{dll}" or one of its dependencies.'                         │
│ ❱  148                 raise err                                                                                     │
│    149                                                                                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
OSError: [WinError 126] The specified module could not be found. Error loading "E:\AI\SDNext\venv\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.

Backend

Original

UI

Standard

Branch

Master

Model

StableDiffusion 1.5

Acknowledgements

ThePixelDiffusionPirate commented 2 months ago

I know nothing about Python and am just muddled through. However, I do a lot of work with the Unreal Engine. Check whether you have the latest version of Microsoft Visual Studio on your PC. It could have something to do with that. Perhaps just the dlls are enough.

MetaverseRPN commented 2 months ago

Does this even need Visual Studio to run?

I know nothing about Python and am just muddled through. However, I do a lot of work with the Unreal Engine. Check whether you have the latest version of Microsoft Visual Studio on your PC. It could have something to do with that. Perhaps just the dlls are enough.

brknsoul commented 1 month ago

You need to install Visual C++ Build Tools https://visualstudio.microsoft.com/visual-cpp-build-tools/ , but only this option image

MetaverseRPN commented 1 month ago

You need to install Visual C++ Build Tools https://visualstudio.microsoft.com/visual-cpp-build-tools/ , but only this option image

This did in fact fix it TYSM!

ameeuwsen commented 1 month ago

You need to install Visual C++ Build Tools https://visualstudio.microsoft.com/visual-cpp-build-tools/ , but only this option image

This was the fix for me as well. Same error as original issue.