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]: Pydantic error on Apple M1 #3265

Closed L0CKZ0R closed 3 months ago

L0CKZ0R commented 3 months ago

Issue Description

Trying to launch gives the following error

Activate python venv: /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv
Launch: venv/bin/python3
14:05:35-457178 INFO     Starting SD.Next                                                                                                                                                
14:05:35-458906 INFO     Logger: file="/Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/sdnext.log" level=DEBUG size=64 mode=create                                                  
14:05:35-459589 INFO     Python version=3.12.4 platform=Darwin bin="/Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/bin/python3" venv="/Volumes/Mac Drive/Stable               
                         Diffusion/SDNext/automatic/venv"                                                                                                                                
14:05:35-499513 INFO     Version: app=sd.next updated=2024-06-13 hash=a3ffd478 branch=master url=https://github.com/vladmandic/automatic/tree/master ui=main                             
14:05:35-500825 DEBUG    Branch mismatch: sdnext=master ui=main                                                                                                                          
14:05:35-546909 DEBUG    Branch synch failed: sdnext=master ui=main                                                                                                                      
14:05:36-174195 INFO     Platform: arch=arm64 cpu=arm system=Darwin release=23.1.0 python=3.12.4                                                                                         
14:05:36-176255 DEBUG    Setting environment tuning                                                                                                                                      
14:05:36-177039 INFO     HF cache folder: /Users/kirynpoole/.cache/huggingface/hub                                                                                                       
14:05:36-177794 DEBUG    Torch allocator: "garbage_collection_threshold:0.80,max_split_size_mb:512"                                                                                      
14:05:36-178293 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False openvino=False                                                                                     
14:05:36-178890 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True                                                                                            
14:05:36-224110 INFO     Verifying requirements                                                                                                                                          
14:05:36-227016 INFO     Verifying packages                                                                                                                                              
14:05:36-238496 DEBUG    Repository update time: Fri Jun 14 04:57:56 2024                                                                                                                
14:05:36-239588 INFO     Startup: standard                                                                                                                                               
14:05:36-239967 INFO     Verifying submodules                                                                                                                                            
14:05:36-688043 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main                                                                                                      
14:05:36-714249 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main                                                                                                   
14:05:36-737450 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main                                                                                                   
14:05:36-766551 DEBUG    Git detached head detected: folder="extensions-builtin/sdnext-modernui" reattach=main                                                                           
14:05:36-767730 DEBUG    Submodule: extensions-builtin/sdnext-modernui / main                                                                                                            
14:05:36-787817 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master                                                                                             
14:05:36-807920 DEBUG    Submodule: modules/k-diffusion / master                                                                                                                         
14:05:36-835998 DEBUG    Git detached head detected: folder="wiki" reattach=master                                                                                                       
14:05:36-837150 DEBUG    Submodule: wiki / master                                                                                                                                        
14:05:36-849989 DEBUG    Register paths                                                                                                                                                  
14:05:36-866408 DEBUG    Installed packages: 166                                                                                                                                         
14:05:36-867008 DEBUG    Extensions all: ['sd-extension-chainner', 'sdnext-modernui', 'stable-diffusion-webui-rembg', 'sd-webui-agent-scheduler', 'Lora', 'sd-extension-system-info']    
14:05:36-897185 DEBUG    Running extension installer: /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/extensions-builtin/stable-diffusion-webui-rembg/install.py                    
14:05:37-016038 DEBUG    Running extension installer: /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/extensions-builtin/sd-webui-agent-scheduler/install.py                        
14:05:37-163313 DEBUG    Extensions all: []                                                                                                                                              
14:05:37-164147 INFO     Extensions enabled: ['sd-extension-chainner', 'sdnext-modernui', 'stable-diffusion-webui-rembg', 'sd-webui-agent-scheduler', 'Lora', 'sd-extension-system-info']
14:05:37-164598 INFO     Verifying requirements                                                                                                                                          
14:05:37-164993 DEBUG    Setup complete without errors: 1718769937                                                                                                                       
14:05:37-166285 DEBUG    Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}                                                                                               
14:05:37-167025 DEBUG    Starting module: <module 'webui' from '/Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/webui.py'>                                                          
14:05:37-167589 INFO     Command line args: ['--debug'] debug=True                                                                                                                       
14:05:37-168035 DEBUG    Env flags: []                                                                                                                                                   
╭────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────╮
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/launch.py:263 in <module>                                                                                                        │
│                                                                                                                                                                                       │
│   262 if __name__ == "__main__":                                                                                                                                                      │
│ ❱ 263     main()                                                                                                                                                                      │
│   264                                                                                                                                                                                 │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/launch.py:240 in main                                                                                                            │
│                                                                                                                                                                                       │
│   239                                                                                                                                                                                 │
│ ❱ 240     uv, instance = start_server(immediate=True, server=None)                                                                                                                    │
│   241     while True:                                                                                                                                                                 │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/launch.py:168 in start_server                                                                                                    │
│                                                                                                                                                                                       │
│   167     get_custom_args()                                                                                                                                                           │
│ ❱ 168     module_spec.loader.exec_module(server)                                                                                                                                      │
│   169     uvicorn = None                                                                                                                                                              │
│ in exec_module:995                                                                                                                                                                    │
│ in _call_with_frames_removed:488                                                                                                                                                      │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/webui.py:11 in <module>                                                                                                          │
│                                                                                                                                                                                       │
│    10 from threading import Thread                                                                                                                                                    │
│ ❱  11 import modules.loader                                                                                                                                                           │
│    12 import torch # pylint: disable=wrong-import-order                                                                                                                               │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/modules/loader.py:42 in <module>                                                                                                 │
│                                                                                                                                                                                       │
│   41                                                                                                                                                                                  │
│ ❱ 42 from fastapi import FastAPI # pylint: disable=W0611,C0411                                                                                                                        │
│   43 import gradio # pylint: disable=W0611,C0411                                                                                                                                      │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/fastapi/__init__.py:7 in <module>                                                              │
│                                                                                                                                                                                       │
│    6                                                                                                                                                                                  │
│ ❱  7 from .applications import FastAPI as FastAPI                                                                                                                                     │
│    8 from .background import BackgroundTasks as BackgroundTasks                                                                                                                       │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/fastapi/applications.py:16 in <module>                                                         │
│                                                                                                                                                                                       │
│     15                                                                                                                                                                                │
│ ❱   16 from fastapi import routing                                                                                                                                                    │
│     17 from fastapi.datastructures import Default, DefaultPlaceholder                                                                                                                 │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/fastapi/routing.py:22 in <module>                                                              │
│                                                                                                                                                                                       │
│     21                                                                                                                                                                                │
│ ❱   22 from fastapi import params                                                                                                                                                     │
│     23 from fastapi._compat import (                                                                                                                                                  │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/fastapi/params.py:5 in <module>                                                                │
│                                                                                                                                                                                       │
│     4                                                                                                                                                                                 │
│ ❱   5 from fastapi.openapi.models import Example                                                                                                                                      │
│     6 from pydantic.fields import FieldInfo                                                                                                                                           │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/fastapi/openapi/models.py:124 in <module>                                                      │
│                                                                                                                                                                                       │
│   123                                                                                                                                                                                 │
│ ❱ 124 class Schema(BaseModelWithConfig):                                                                                                                                              │
│   125     # Ref: JSON Schema 2020-12: https://json-schema.org/draft/2020-12/json-schema-core.html#name-the-json-schema-core-vocabu                                                    │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/pydantic/main.py:286 in __new__                                                                │
│                                                                                                                                                                                       │
│    285         if resolve_forward_refs:                                                                                                                                               │
│ ❱  286             cls.__try_update_forward_refs__()                                                                                                                                  │
│    287                                                                                                                                                                                │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/pydantic/main.py:807 in __try_update_forward_refs__                                            │
│                                                                                                                                                                                       │
│    806         """                                                                                                                                                                    │
│ ❱  807         update_model_forward_refs(cls, cls.__fields__.values(), cls.__config__.json_encoders, localns, (NameError,))                                                           │
│    808                                                                                                                                                                                │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/pydantic/typing.py:554 in update_model_forward_refs                                            │
│                                                                                                                                                                                       │
│   553         try:                                                                                                                                                                    │
│ ❱ 554             update_field_forward_refs(f, globalns=globalns, localns=localns)                                                                                                    │
│   555         except exc_to_suppress:                                                                                                                                                 │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/pydantic/typing.py:520 in update_field_forward_refs                                            │
│                                                                                                                                                                                       │
│   519         prepare = True                                                                                                                                                          │
│ ❱ 520         field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)                                                                                               │
│   521     if field.outer_type_.__class__ == ForwardRef:                                                                                                                               │
│                                                                                                                                                                                       │
│ /Volumes/Mac Drive/Stable Diffusion/SDNext/automatic/venv/lib/python3.12/site-packages/pydantic/typing.py:66 in evaluate_forwardref                                                   │
│                                                                                                                                                                                       │
│    65         # `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast...                                                                                         │
│ ❱  66         return cast(Any, type_)._evaluate(globalns, localns, set())                                                                                                             │
│    67                                                                                                                                                                                 │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

Version Platform Description

Mac M1, Sonoma.

Relevant log output

No response

Backend

Original

Branch

Master

Model

Other

Acknowledgements

vladmandic commented 3 months ago

please provide output of:

source venv/bin/activate
pip show fastapi pydantic

and then try:

pip install pydantic==1.10.15

krummrey commented 3 months ago

I'm have the same issue. Here's my output:

Name: fastapi
Version: 0.111.0
Summary: FastAPI framework, high performance, easy to learn, fast to code, ready for production
Home-page: 
Author: 
Author-email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
License: 
Location: /Users/xxx/Documents/automatic/venv/lib/python3.12/site-packages
Requires: email_validator, fastapi-cli, httpx, jinja2, orjson, pydantic, python-multipart, starlette, typing-extensions, ujson, uvicorn
Required-by: gradio
---
Name: pydantic
Version: 1.10.15
Summary: Data validation and settings management using python type hints
Home-page: https://github.com/pydantic/pydantic
Author: Samuel Colvin
Author-email: s@muelcolvin.com
License: MIT
Location: /Users/xxx/Documents/automatic/venv/lib/python3.12/site-packages
Requires: typing-extensions
Required-by: fastapi, gradio

pip install pydantic==1.10.15

Requirement already satisfied: pydantic==1.10.15 in ./venv/lib/python3.12/site-packages (1.10.15)
Requirement already satisfied: typing-extensions>=4.2.0 in ./venv/lib/python3.12/site-packages (from pydantic==1.10.15) (4.11.0)
vladmandic commented 3 months ago

digging a bit deeper, which python? run python --version.

seems like python 3.12.4 introduced new params in one internal method that is not recognized by other packages.
i've tested with python 3.12.3 and it works.

note that python 3.12 in general is considered experimentally supported only and NOT recommended.
recommended is 3.10 or 3.11.
and no, you don't have to modify system python, you can side-install any python version.

vladmandic commented 3 months ago

closing as root cause has been provided.