AUTOMATIC1111 / stable-diffusion-webui

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

[Bug]: "AttributeError: __config__" in "sagemaker studio lab" #12680

Open overchoke2128 opened 1 year ago

overchoke2128 commented 1 year ago

Is there an existing issue for this?

What happened?

스크린샷(146)

The bug shown in the picture occurred while installing stable diffusion with sagemaker studio lab.

Steps to reproduce the problem

  1. use this notebook https://gist.github.com/ShMcK/d14d90abea1437fdc9cfe8ecda864b06

  2. run the whole process

  3. Execute all processes except "Run: Launch web ui"

  4. 스크린샷(149) Add "--xformers"

5.fix error need to change to "from pytorch_lightning.utilities.rank_zero"

6.Pray to all the gods in the world and execute "Run: Launch web ui"

7.Traceback (most recent call last): File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/launch.py", line 39, in main() File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/launch.py", line 35, in main start() File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/launch_utils.py", line 394, in start webui.webui() File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/webui.py", line 393, in webui shared.demo = modules.ui.create_ui() File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/ui.py", line 504, in create_ui modules.scripts.scripts_txt2img.setup_ui_for_section(category) File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/scripts.py", line 433, in setup_ui_for_section self.create_script_ui(script) File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/scripts.py", line 383, in create_script_ui import modules.api.models as api_models File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/api/models.py", line 101, in StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator( File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/api/models.py", line 97, in generate_model DynamicModel.config.allow_population_by_field_name = True File "/home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 210, in getattr raise AttributeError(item) AttributeError: config Creating model from config: /home/studio-lab-user/SageMaker/stable-diffusion-webui/configs/v1-inference.yaml LatentDiffusion: Running in eps-prediction mode DiffusionWrapper has 859.52 M params. Applying attention optimization: xformers... done. Model loaded in 4.1s (load weights from disk: 0.3s, create model: 1.2s, apply weights to model: 1.3s, apply half(): 0.6s, move model to device: 0.6s).

What should have happened?

A URL that allows you to run "stable diffusion" appears.

Something like "ngork error:3200,3004" does not appear and the webui works fine.

Version or Commit where the problem happens

https://gist.github.com/ShMcK/d14d90abea1437fdc9cfe8ecda864b06

What Python version are you running on ?

Python 3.9.x (below, no recommended)

What platforms do you use to access the UI ?

Other/Cloud

What device are you running WebUI on?

Other GPUs

Cross attention optimization

xformers

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

#!/bin/bash
#########################################################
# Uncomment and change the variables below to your need:#
#########################################################

# Install directory without trailing slash
#install_dir="/home/$(whoami)"

# Name of the subdirectory
#clone_dir="stable-diffusion-webui"

# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
#export COMMANDLINE_ARGS=""

# python3 executable
#python_cmd="python3"

# git executable
#export GIT="git"

# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
#venv_dir="venv"

# script to launch to start the app
#export LAUNCH_SCRIPT="launch.py"

# install command for torch
#export TORCH_COMMAND="pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113"

# Requirements file to use for stable-diffusion-webui
#export REQS_FILE="requirements_versions.txt"

# Fixed git repos
#export K_DIFFUSION_PACKAGE=""
#export GFPGAN_PACKAGE=""

# Fixed git commits
#export STABLE_DIFFUSION_COMMIT_HASH=""
#export CODEFORMER_COMMIT_HASH=""
#export BLIP_COMMIT_HASH=""

# Uncomment to enable accelerated launch
#export ACCELERATE="True"

# Uncomment to disable TCMalloc
#export NO_TCMALLOC="True"

###########################################

List of extensions

no

Console logs

Saving ngrok auth token to ~/.ngrok_token
/home/studio-lab-user/SageMaker/stable-diffusion-webui
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:39:03) 
[GCC 11.3.0]
Version: v1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Launching Web UI with arguments: --xformers --disable-console-progressbars --gradio-debug --gradio-auth 1:2 --ngrok xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ngrok authtoken detected, trying to connect...
ngrok connected to localhost:7860! URL: https://65b8-3-135-152-169.ngrok-free.app
You can use this link after the launch is complete.
Checkpoint  not found; loading fallback v1-5-pruned-emaonly.safetensors [6ce0161689]
Loading weights [6ce0161689] from /home/studio-lab-user/SageMaker/stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors
Traceback (most recent call last):
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/launch.py", line 39, in <module>
    main()
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/launch.py", line 35, in main
    start()
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/launch_utils.py", line 394, in start
    webui.webui()
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/webui.py", line 393, in webui
    shared.demo = modules.ui.create_ui()
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/ui.py", line 504, in create_ui
    modules.scripts.scripts_txt2img.setup_ui_for_section(category)
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/scripts.py", line 433, in setup_ui_for_section
    self.create_script_ui(script)
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/scripts.py", line 383, in create_script_ui
    import modules.api.models as api_models
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/api/models.py", line 101, in <module>
    StableDiffusionTxt2ImgProcessingAPI = PydanticModelGenerator(
  File "/home/studio-lab-user/SageMaker/stable-diffusion-webui/modules/api/models.py", line 97, in generate_model
    DynamicModel.__config__.allow_population_by_field_name = True
  File "/home/studio-lab-user/.conda/envs/default/lib/python3.9/site-packages/pydantic/_internal/_model_construction.py", line 210, in __getattr__
    raise AttributeError(item)
AttributeError: __config__
Creating model from config: /home/studio-lab-user/SageMaker/stable-diffusion-webui/configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying attention optimization: xformers... done.
Model loaded in 4.1s (load weights from disk: 0.3s, create model: 1.2s, apply weights to model: 1.3s, apply half(): 0.6s, move model to device: 0.6s).

Additional information

I hope this can be resolved... To solve this error, it is the 12th day to ask many large sites in Korea, fix it, and fail. Seniors, please, I beg you very earnestly. . . .please save me

catboxanon commented 1 year ago

You're using a version of Pydantic that's not supported by the webui. I believe it gets installed as a dependency of fastapi. You probably want to try installing the requirements from requirements_versions.txt rather than requirements.txt. The one without requirements really only applies to Google Colab to my knowledge.

wocanbe commented 1 year ago

I also encountered the same problem. I guess it was caused by the pydantic's version, but I don't know which version to use or what to solve it.this has't pydantic version config at requirements_versions.txt

ZeroBomb commented 11 months ago

To clarify somewhat:

This is caused by upgrading the pydantic version to 2.x.

In pydantic version 1.x, calling the create_model method produces an object that contains a config property, while in 2.x that is deprecated and now needs to be explicitly created with a model_config class attribute.

To fix this, the generate_model method in modules/api/models.py needs to be updated according to the migration document I linked above.