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.68k stars 421 forks source link

[Issue]: WebUI fails to load, "File not found" errors #3008

Closed Hew-ux closed 7 months ago

Hew-ux commented 7 months ago

Issue Description

When starting the webui using webui.sh, the page is forever stuck on "Loading" as pictured: image In the console there are a series of errors saying "404: File not found".

12:52:08-233573 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=javascript/localStorage.js?1710990011.7290
                         01 {'error': 'HTTPException', 'code': 404, 'detail': 'File not found:
                         javascript/localStorage.js.', 'body': '', 'errors': '404: File not   
                         found: javascript/localStorage.js.'}                                 
12:52:08-235617 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=javascript/textualInversion.js?1710990011.
                         730001 {'error': 'HTTPException', 'code': 404, 'detail': 'File not   
                         found: javascript/textualInversion.js.', 'body': '', 'errors': '404: 
                         File not found: javascript/textualInversion.js.'}                    
12:52:08-238841 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=style.css?1710990011.7470012 {'error':    
                         'HTTPException', 'code': 404, 'detail': 'File not found: style.css.',
                         'body': '', 'errors': '404: File not found: style.css.'}             
12:52:08-240616 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=extensions-builtin/canvas-zoom-and-pan/sty
                         le.css?1710990011.727001 {'error': 'HTTPException', 'code': 404,     
                         'detail': 'File not found:                                           
                         extensions-builtin/canvas-zoom-and-pan/style.css.', 'body': '',      
                         'errors': '404: File not found:                                      
                         extensions-builtin/canvas-zoom-and-pan/style.css.'}                  
12:52:08-375720 ERROR    API error: GET: http://127.0.0.1:7860/assets/Blocks-b3881047.js      
                         {'error': 'HTTPException', 'code': 404, 'detail': 'File not found',  
                         'body': '', 'errors': '404: File not found'}                         
12:52:08-377515 ERROR    API error: GET: http://127.0.0.1:7860/assets/Button-748313a7.js      
                         {'error': 'HTTPException', 'code': 404, 'detail': 'File not found',  
                         'body': '', 'errors': '404: File not found'} 

I followed the installation instructions while in an anaconda environment for Python 3.10, however testing it again without the Anaconda environment yields the same result so I don't suspect that it was the cause. I have the full output of both my installation and my attempts to launch and use the webui (inside and outside the anaconda environment) here: File missing error debug output.txt

Version Platform Description

OS: Fedora Browser: Floorp (Firefox fork)

12:05:21-698398 INFO     Starting SD.Next
12:05:21-700860 INFO     Logger: file="/home/user/Applications/SD Next/automatic/sdnext.log"
                         level=DEBUG size=64 mode=create
12:05:21-701692 INFO     Python 3.10.14 on Linux
12:05:21-711704 INFO     Version: app=sd.next updated=2024-03-21 hash=82973c49 branch=master
                         url=https://github.com/vladmandic/automatic/tree/master
12:05:21-716318 INFO     Platform: arch=x86_64 cpu= system=Linux release=6.7.9-200.fc39.x86_64
                         python=3.10.14
12:05:21-717459 DEBUG    Setting environment tuning
12:05:21-718162 DEBUG    HF cache folder: /home/user/.cache/huggingface/hub
12:05:21-718805 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False
                         openvino=False
12:05:21-719555 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True
12:05:21-721331 INFO     nVidia CUDA toolkit detected: nvidia-smi present

Relevant log output

Create and activate python venv
Launching launch.py...
12:51:41-892411 INFO     Starting SD.Next                                                     
12:51:41-895197 INFO     Logger: file="/home/niroku/Applications/SD Next/automatic/sdnext.log"
                         level=DEBUG size=64 mode=create                                      
12:51:41-896317 INFO     Python 3.10.14 on Linux                                              
12:51:41-906822 INFO     Version: app=sd.next updated=2024-03-21 hash=82973c49 branch=master  
                         url=https://github.com/vladmandic/automatic/tree/master              
12:51:42-343884 INFO     Platform: arch=x86_64 cpu= system=Linux release=6.7.9-200.fc39.x86_64
                         python=3.10.14                                                       
12:51:42-345187 DEBUG    Setting environment tuning                                           
12:51:42-345952 DEBUG    HF cache folder: /home/niroku/.cache/huggingface/hub                 
12:51:42-346658 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False         
                         openvino=False                                                       
12:51:42-347540 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True 
12:51:42-348490 INFO     nVidia CUDA toolkit detected: nvidia-smi present                     
12:51:42-349520 DEBUG    Installing torch: torch torchvision --index-url                      
                         https://download.pytorch.org/whl/cu121                               
12:51:42-364465 DEBUG    Repository update time: Thu Mar 21 13:23:50 2024                     
12:51:42-365690 INFO     Startup: standard                                                    
12:51:42-366250 INFO     Verifying requirements                                               
12:51:42-376622 INFO     Verifying packages                                                   
12:51:42-378076 INFO     Verifying submodules                                                 
12:51:42-568143 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main           
12:51:42-576106 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main        
12:51:42-583297 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main        
12:51:42-590813 DEBUG    Submodule: extensions-builtin/sd-webui-controlnet / main             
12:51:42-603187 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-images-browser /
                         main                                                                 
12:51:42-611267 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master  
12:51:42-618656 DEBUG    Submodule: modules/k-diffusion / master                              
12:51:42-626607 DEBUG    Submodule: wiki / master                                             
12:51:42-631933 DEBUG    Register paths                                                       
12:51:42-683676 DEBUG    Installed packages: 243                                              
12:51:42-684828 DEBUG    Extensions all: ['Lora', 'sd-extension-chainner',                    
                         'sd-extension-system-info', 'sd-webui-agent-scheduler',              
                         'sd-webui-controlnet', 'stable-diffusion-webui-images-browser',      
                         'stable-diffusion-webui-rembg']                                      
12:51:42-784548 DEBUG    Running extension installer: /home/niroku/Applications/SD            
                         Next/automatic/extensions-builtin/sd-extension-system-info/install.py
12:51:42-969643 DEBUG    Running extension installer: /home/niroku/Applications/SD            
                         Next/automatic/extensions-builtin/sd-webui-agent-scheduler/install.py
12:51:43-153908 DEBUG    Running extension installer: /home/niroku/Applications/SD            
                         Next/automatic/extensions-builtin/sd-webui-controlnet/install.py     
12:51:43-360635 DEBUG    Running extension installer: /home/niroku/Applications/SD            
                         Next/automatic/extensions-builtin/stable-diffusion-webui-images-brows
                         er/install.py                                                        
12:51:43-544076 DEBUG    Running extension installer: /home/niroku/Applications/SD            
                         Next/automatic/extensions-builtin/stable-diffusion-webui-rembg/instal
                         l.py                                                                 
12:51:43-730483 DEBUG    Extensions all: []                                                   
12:51:43-731527 INFO     Extensions enabled: ['Lora', 'sd-extension-chainner',                
                         'sd-extension-system-info', 'sd-webui-agent-scheduler',              
                         'sd-webui-controlnet', 'stable-diffusion-webui-images-browser',      
                         'stable-diffusion-webui-rembg']                                      
12:51:43-732366 INFO     Verifying requirements                                               
12:51:43-759693 DEBUG    Setup complete without errors: 1711504304                            
12:51:43-761993 DEBUG    Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}    
12:51:43-763026 DEBUG    Starting module: <module 'webui' from '/home/niroku/Applications/SD  
                         Next/automatic/webui.py'>                                            
12:51:43-764318 INFO     Command line args: ['--debug'] debug=True                            
12:51:43-765114 DEBUG    Env flags: []                                                        
12:51:47-437620 INFO     Load packages: {'torch': '2.2.2+cu121', 'diffusers': '0.27.0',       
                         'gradio': '3.43.2'}                                                  
12:51:48-199245 DEBUG    Read: file="config.json" json=18 bytes=721 time=0.000                
12:51:48-202888 INFO     Engine: backend=Backend.DIFFUSERS compute=cuda device=cuda           
                         attention="Scaled-Dot-Product" mode=no_grad                          
12:51:48-244349 INFO     Device: device=NVIDIA GeForce RTX 3060 n=1 arch=sm_90 cap=(8, 6)     
                         cuda=12.1 cudnn=8902 driver=550.67                                   
12:51:48-245975 DEBUG    Read: file="html/reference.json" json=36 bytes=21248 time=0.000      
12:51:48-441639 DEBUG    Importing LDM                                                        
12:51:48-451504 DEBUG    Entering start sequence                                              
12:51:48-452787 DEBUG    Initializing                                                         
12:51:48-463847 INFO     Available VAEs: path="models/VAE" items=0                            
12:51:48-464981 INFO     Disabled extensions: ['sd-webui-controlnet']                         
12:51:48-465837 DEBUG    Scanning diffusers cache: folder=models/Diffusers items=0 time=0.00  
12:51:48-466573 INFO     Available models: path="models/Stable-diffusion" items=0 time=0.00   
12:51:48-600473 DEBUG    Load extensions                                                      
12:51:48-635146 INFO     LoRA networks: available=0 folders=2                                 
12:51:48-878759 INFO     Extension:                                                           
                         script='extensions-builtin/sd-webui-agent-scheduler/scripts/task_sche
                         duler.py' Using sqlite file:                                         
                         extensions-builtin/sd-webui-agent-scheduler/task_scheduler.sqlite3   
12:51:49-031434 DEBUG    Extensions init time: 0.43 sd-webui-agent-scheduler=0.23             
                         stable-diffusion-webui-images-browser=0.14                           
12:51:49-037197 DEBUG    Read: file="html/upscalers.json" json=4 bytes=2640 time=0.000        
12:51:49-038216 DEBUG    Read: file="extensions-builtin/sd-extension-chainner/models.json"    
                         json=24 bytes=2693 time=0.000                                        
12:51:49-039351 DEBUG    chaiNNer models: path="models/chaiNNer" defined=24 discovered=0      
                         downloaded=0                                                         
12:51:49-040731 DEBUG    Load upscalers: total=52 downloaded=0 user=0 time=0.01 ['None',      
                         'Lanczos', 'Nearest', 'ChaiNNer', 'ESRGAN', 'LDSR', 'RealESRGAN',    
                         'SCUNet', 'SD', 'SwinIR']                                            
12:51:49-046253 DEBUG    Load styles: folder="models/styles" items=288 time=0.00              
12:51:49-048225 DEBUG    Creating UI                                                          
12:51:49-049060 INFO     UI theme: name="black-teal" style=Auto base=sdnext.css               
12:51:49-052013 DEBUG    UI initialize: txt2img                                               
12:51:49-067908 DEBUG    Extra networks: page='model' items=36 subfolders=2 tab=txt2img       
                         folders=['models/Stable-diffusion', 'models/Diffusers',              
                         'models/Reference'] list=0.01 thumb=0.00 desc=0.00 info=0.00         
                         workers=4                                                            
12:51:49-076775 DEBUG    Extra networks: page='style' items=288 subfolders=1 tab=txt2img      
                         folders=['models/styles', 'html'] list=0.01 thumb=0.00 desc=0.00     
                         info=0.00 workers=4                                                  
12:51:49-280315 DEBUG    Extra networks: page='embedding' items=0 subfolders=0 tab=txt2img    
                         folders=['models/embeddings'] list=0.00 thumb=0.00 desc=0.00         
                         info=0.00 workers=4                                                  
12:51:49-281964 DEBUG    Extra networks: page='hypernetwork' items=0 subfolders=0 tab=txt2img 
                         folders=['models/hypernetworks'] list=0.00 thumb=0.00 desc=0.00      
                         info=0.00 workers=4                                                  
12:51:49-283398 DEBUG    Extra networks: page='vae' items=0 subfolders=0 tab=txt2img          
                         folders=['models/VAE'] list=0.00 thumb=0.00 desc=0.00 info=0.00      
                         workers=4                                                            
12:51:49-284718 DEBUG    Extra networks: page='lora' items=0 subfolders=0 tab=txt2img         
                         folders=['models/Lora', 'models/LyCORIS'] list=0.00 thumb=0.00       
                         desc=0.00 info=0.00 workers=4                                        
12:51:49-349396 DEBUG    UI initialize: img2img                                               
12:51:49-437650 DEBUG    UI initialize: control models=models/control                         
12:51:49-643029 DEBUG    Read: file="ui-config.json" json=0 bytes=2 time=0.000                
12:51:49-740555 DEBUG    Themes: builtin=12 gradio=5 huggingface=0                            
12:51:50-407105 INFO     Extension list is empty: refresh required                            
12:51:50-452681 DEBUG    Extension list: processed=7 installed=7 enabled=6 disabled=1         
                         visible=7 hidden=0                                                   
12:51:50-599635 DEBUG    Root paths: ['/home/niroku/Applications/SD Next/automatic']          
12:51:50-670707 INFO     Local URL: http://127.0.0.1:7860/                                    
12:51:50-671636 DEBUG    Gradio functions: registered=2145                                    
12:51:50-672815 DEBUG    FastAPI middleware: ['Middleware', 'Middleware']                     
12:51:50-675397 DEBUG    Creating API                                                         
12:51:50-832994 INFO     [AgentScheduler] Task queue is empty                                 
12:51:50-834049 INFO     [AgentScheduler] Registering APIs                                    
12:51:51-256160 DEBUG    Scripts setup: ['IP Adapters:0.014', 'AnimateDiff:0.008', 'X/Y/Z     
                         Grid:0.011', 'Face:0.011', 'Image-to-Video:0.005']                   
12:51:51-257477 DEBUG    Model metadata: file="metadata.json" no changes                      
12:51:51-258683 DEBUG    Model requested: fn=<lambda>                                         
12:51:51-259722 WARNING  Cannot generate without a checkpoint                                 
12:51:51-260339 INFO     Set system paths to use existing folders in a different location     
12:51:51-260939 INFO       or use --models-dir <path-to-folder> to specify base folder with   
                         all models                                                           
12:51:51-261638 INFO       or use --ckpt-dir <path-to-folder> to specify folder with sd models
12:51:51-262542 INFO       or use --ckpt <path-to-checkpoint> to force using existing model   
12:51:51-263811 DEBUG    Script callback init time: image_browser.py:ui_tabs=0.55             
                         system-info.py:app_started=0.07 task_scheduler.py:app_started=0.44   
12:51:51-265109 INFO     Startup time: 7.49 torch=2.92 gradio=0.71 libraries=1.00             
                         extensions=0.43 face-restore=0.13 ui-en=0.31 ui-img2img=0.06         
                         ui-control=0.10 ui-settings=0.21 ui-extensions=0.63 ui-defaults=0.07 
                         launch=0.13 api=0.08 app-started=0.50                                
12:51:51-268013 DEBUG    Save: file="config.json" json=18 bytes=721 time=0.004                
12:52:00-277272 DEBUG    Server: alive=True jobs=1 requests=1 uptime=12 memory=0.91/31.21     
                         backend=Backend.DIFFUSERS state=idle                                 
12:52:08-233573 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=javascript/localStorage.js?1710990011.7290
                         01 {'error': 'HTTPException', 'code': 404, 'detail': 'File not found:
                         javascript/localStorage.js.', 'body': '', 'errors': '404: File not   
                         found: javascript/localStorage.js.'}                                 
12:52:08-235617 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=javascript/textualInversion.js?1710990011.
                         730001 {'error': 'HTTPException', 'code': 404, 'detail': 'File not   
                         found: javascript/textualInversion.js.', 'body': '', 'errors': '404: 
                         File not found: javascript/textualInversion.js.'}                    
12:52:08-238841 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=style.css?1710990011.7470012 {'error':    
                         'HTTPException', 'code': 404, 'detail': 'File not found: style.css.',
                         'body': '', 'errors': '404: File not found: style.css.'}             
12:52:08-240616 ERROR    API error: GET:                                                      
                         http://127.0.0.1:7860/file=extensions-builtin/canvas-zoom-and-pan/sty
                         le.css?1710990011.727001 {'error': 'HTTPException', 'code': 404,     
                         'detail': 'File not found:                                           
                         extensions-builtin/canvas-zoom-and-pan/style.css.', 'body': '',      
                         'errors': '404: File not found:                                      
                         extensions-builtin/canvas-zoom-and-pan/style.css.'}                  
12:52:08-375720 ERROR    API error: GET: http://127.0.0.1:7860/assets/Blocks-b3881047.js      
                         {'error': 'HTTPException', 'code': 404, 'detail': 'File not found',  
                         'body': '', 'errors': '404: File not found'}                         
12:52:08-377515 ERROR    API error: GET: http://127.0.0.1:7860/assets/Button-748313a7.js      
                         {'error': 'HTTPException', 'code': 404, 'detail': 'File not found',  
                         'body': '', 'errors': '404: File not found'}                         
^C12:52:19-826069 INFO     Exiting

Backend

Original

Branch

Master

Model

SD 1.5

Acknowledgements

vladmandic commented 7 months ago

this basically means that any request that browser makes cannot be found on the server at all.

it probably doesn't matter, but can you test with clean install on path without spaces?
your current install folder is /home/niroku/Applications/SD Next/automatic

also, no need for anaconda since sdnext will create and use venv. and venv inside conda makes no sense

Hew-ux commented 7 months ago

When attempting to follow the install instructions directly, it says that it is an incompatible Pyhthon version, hence why I was using anaconda in the first place. Could this be the cause of the issue?

Here is the output from the folder /home/niroku/Applications/SDNext:

[user@computer SDNext]$ git clone https://github.com/vladmandic/automatic
Cloning into 'automatic'...
remote: Enumerating objects: 43103, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (106/106), done.
remote: Total 43103 (delta 112), reused 189 (delta 100), pack-reused 42896
Receiving objects: 100% (43103/43103), 53.45 MiB | 2.76 MiB/s, done.
Resolving deltas: 100% (31092/31092), done.
[user@computer SDNext]$ cd automatic/
[user@computer automatic]$ ./webui.sh
Create and activate python venv
Launching launch.py...
17:49:14-526368 INFO     Starting SD.Next                                                     
17:49:14-528822 INFO     Logger: file="/home/niroku/Applications/SDNext/automatic/sdnext.log" 
                         level=INFO size=64 mode=append                                       
17:49:14-529737 INFO     Python 3.12.2 on Linux                                               
17:49:14-530373 ERROR    Incompatible Python version: 3.12.2 required 3.[9, 10, 11]           
[user@computer automatic]$ 
vladmandic commented 7 months ago

that part is clear - and possible usage of python 3.12 is documented in wiki - but that is not what caused the original issue. and you don't need conda to specify different python, simply set env variable PYTHON=path_to_python before starting sdnext and it will use whichever python you choose.

for example:

export PYTHON=/bin/python3.11 ./webui.sh --debug

Hew-ux commented 7 months ago

I erased the folder entirely and re-cloned the repo. I also erased the conda environment. Then, following those instructions verbatim:

[user@computer SDNext]$ export PYTHON=/bin/python3.11
[user@computer SDNext]$ export -p | grep "PYTHON"
declare -x PYTHON="/bin/python3.11"
[user@computer SDNext]$ cd automatic/
[user@computer automatic]$ ./webui.sh --debug
Create and activate python venv
Launching launch.py...
Traceback (most recent call last):
  File "/home/niroku/Applications/SDNext/automatic/installer.py", line 12, in <module>
    import pkg_resources # python 3.12 no longer has it built-in
    ^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pkg_resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/niroku/Applications/SDNext/automatic/launch.py", line 9, in <module>
    import installer
  File "/home/niroku/Applications/SDNext/automatic/installer.py", line 15, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
[user@computer automatic]$ 

Using Python 3.10 also has the same result. I erased the venv folder before doing this.

vladmandic commented 7 months ago

that's strange. i'll check, but this is in webui.sh

if [[ -z "${PYTHON}" ]]
then
    PYTHON="python3"
fi
...
exec "${PYTHON}" launch.py "$@"

so it should use whatever python is specified in PYTHON env variable.

Hew-ux commented 7 months ago

I did some investigating. In the /lib/python3.10/site-packages directory there are no folders at all. It could just be that Fedora's meta package for Python 3.10 just doesn't include these things; I'm not knowledgeable enough about Fedora to know why it isn't included in that package and which one would be needed to resolve this, if there is any at all. Anaconda is currently my only method to install this on my OS.

Anyway, I still had a backup of my first attempt so I tried cloning the repo again and then directly copying the venv folder from the already installed one to the new one, bypassing the need to use the script install the virtual Python environment. This way we can solely focus on the issue at hand, why it isn't installing the required web components.

Here is the output of ./webui.sh --debug after doing that (there was a lot of message spam so the top was cut off by the scrollback limit; I try again with better results): output.txt

It works! But it seems like there are some hard-coded paths in the venv that was copied over.

To be sure, I repeated the test, this time copying into a folder name "SD Test", with a space in it. This was also a success, so it's not likely that it's because the folder had a space in it. I managed to capture the top of the output in this one, it has a lot of warnings about missing files but the UI itself is loading okay: top-of-output.txt

vladmandic commented 7 months ago

this latest test is going in a direction that cannot be troubleshooted - too many manual interventions. also, i'm not sure if having conda env is related or not, but again - too many variables. so to progress here, we need to have:

Hew-ux commented 7 months ago

This is turning more into a "Is python installed correctly?" issue than anything to do with SD Next. I cannot find a solution to getting Python 3.10 installed in a functioning state natively in Fedora. I ran sudo dnf install python3.10, installing all the "weak dependencies". I pulled the latest dev branch of SD Next into a new folder, exported the python version, and then ran webui.sh. It says Error: python3-venv is not installed. Which is different from last time, where it complained about missing static packages, (in my earlier test, I used dnfdragora to install the python3.10 packages, which should be identical to using dnf from the command line).

I have searched online for methods to install specifically python3.10 in Fedora, and all sources says to run the command as I did above. A lot of this nonsense is the reason I was using Anaconda in the first place, so I could just say "setup an environment with Python3.10", and it works. But if Anaconda is the thing causing the issue, then the point is moot.

I had thought the issue might be during SD Next's own installation (after python and everything else was sorted) considering it was only web components failing to download and the program itself runs from the virtual python environment installed in venv folder. But it could very well be this is just an issue with anaconda/Fedora's packaging of older Python versions.

It should be noted in the installation instructions for Linux that "a valid python 3.10 or 3.11 installation" is required here: https://github.com/vladmandic/automatic/wiki/Installation#install-python-and-git

I can consistently reproduce the issue using my anaconda setup, but if it can't be reproduced in an ordinary environment then it's fair game to say this is not an issue with SD Next itself worth investigating. I appreciate you spending time looking into this, but I don't want to waste your time on what is probably an OS issue. Hopefully this information is helpful to other users in some way, even if it's just to confirm that Fedora may have some issues with older Python versions.

vladmandic commented 7 months ago

thanks for the follow-up writeup!