stable-diffusion-webui-docker icon indicating copy to clipboard operation
stable-diffusion-webui-docker copied to clipboard

ImportError: cannot import name 'url_quote' from 'werkzeug.urls'

Open YuanfengZhang opened this issue 2 years ago • 2 comments

Has this issue been opened before?

  • [x] It is not in the FAQ, I checked.
  • [x] It is not in the issues, I searched.

Describe the bug

invoke try

sudo docker compose --profile invoke up --build

returned:

[+] Building 1.0s (17/17) FINISHED                                                                   docker:default
 => [invoke internal] load .dockerignore                                                                       0.0s
 => => transferring context: 2B                                                                                0.0s
 => [invoke internal] load build definition from Dockerfile                                                    0.0s
 => => transferring dockerfile: 2.37kB                                                                         0.0s
 => [invoke internal] load metadata for docker.io/pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime                0.7s
 => [invoke internal] load metadata for docker.io/library/alpine:3.17                                          1.0s
 => [invoke xformers 1/2] FROM docker.io/library/alpine:3.17@sha256:f71a5f071694a785e064f05fed657bf8277f1b211  0.0s
 => [invoke stage-1 1/9] FROM docker.io/pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime@sha256:82e0d379a5dedd63  0.0s
 => [invoke internal] load build context                                                                       0.0s
 => => transferring context: 96B                                                                               0.0s
 => CACHED [invoke stage-1 2/9] RUN --mount=type=cache,target=/var/cache/apt   apt-get update &&   apt-get in  0.0s
 => CACHED [invoke stage-1 3/9] RUN git clone https://github.com/invoke-ai/InvokeAI.git /InvokeAI              0.0s
 => CACHED [invoke stage-1 4/9] WORKDIR /InvokeAI                                                              0.0s
 => CACHED [invoke stage-1 5/9] RUN --mount=type=cache,target=/root/.cache/pip   git reset --hard f3b2e029219  0.0s
 => CACHED [invoke stage-1 6/9] RUN --mount=type=cache,target=/root/.cache/pip   git fetch &&   git reset --h  0.0s
 => CACHED [invoke stage-1 7/9] RUN --mount=type=cache,target=/root/.cache/pip   pip uninstall -y torchmetric  0.0s
 => CACHED [invoke xformers 2/2] COPY wheel.whl /                                                              0.0s
 => CACHED [invoke stage-1 8/9] RUN --mount=type=cache,target=/root/.cache/pip   --mount=type=bind,from=xform  0.0s
 => CACHED [invoke stage-1 9/9] COPY . /docker/                                                                0.0s
 => [invoke] exporting to image                                                                                0.0s
 => => exporting layers                                                                                        0.0s
 => => writing image sha256:72c3dd3cfae48404e4994df16cd85fc6d5aa5707956a7388c023146f00511906                   0.0s
 => => naming to docker.io/library/sd-invoke:30                                                                0.0s
[+] Running 1/0
 ✔ Container webui-docker-invoke-1  Created                                                                    0.0s 
Attaching to webui-docker-invoke-1
webui-docker-invoke-1  | Mounted ldm
webui-docker-invoke-1  | Mounted .cache
webui-docker-invoke-1  | Mounted RealESRGAN
webui-docker-invoke-1  | Mounted Codeformer
webui-docker-invoke-1  | Mounted GFPGAN
webui-docker-invoke-1  | Mounted GFPGANv1.4.pth
webui-docker-invoke-1  | Loading Python libraries...
webui-docker-invoke-1  | 
webui-docker-invoke-1  | * Initializing, be patient...
webui-docker-invoke-1  | >> Initialization file /InvokeAI/invokeai.init found. Loading...
webui-docker-invoke-1  | 
webui-docker-invoke-1  | ** DOWNLOADING SUPPORT MODELS **
webui-docker-invoke-1  | Installing bert tokenizer...
webui-docker-invoke-1  | Installing SD1 clip model...
webui-docker-invoke-1  | Installing SD2 clip model...
webui-docker-invoke-1  | Installing models from RealESRGAN...
webui-docker-invoke-1  | Installing RealESRGAN model file https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth......exists
webui-docker-invoke-1  | Installing RealESRGANwdn model file https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth......exists
webui-docker-invoke-1  | Installing GFPGAN models...
webui-docker-invoke-1  | Installing GFPGAN weights model file https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth......exists
webui-docker-invoke-1  | Installing GFPGAN weights model file https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth......exists
webui-docker-invoke-1  | Installing GFPGAN weights model file https://github.com/xinntao/facexlib/releases/download/v0.2.2/parsing_parsenet.pth......exists
webui-docker-invoke-1  | Installing CodeFormer model file...
webui-docker-invoke-1  | Installing CodeFormer model file https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth......exists
webui-docker-invoke-1  | Installing clipseg model for text-based masking...
webui-docker-invoke-1  | Installing model for NSFW content detection...
webui-docker-invoke-1  | AutoFeatureExtractor...
webui-docker-invoke-1  | StableDiffusionSafetyChecker...
webui-docker-invoke-1  | Installing stabilityai VAE...
webui-docker-invoke-1  | * vae-ft-mse-840000-ema-pruned.ckpt: complete file found. Skipping.
webui-docker-invoke-1  | 
webui-docker-invoke-1  | ** DOWNLOADING DIFFUSION WEIGHTS **
webui-docker-invoke-1  | == INSTALLING SELECTED STARTER MODELS ==
webui-docker-invoke-1  | Downloading stable-diffusion-1.5:
webui-docker-invoke-1  | Downloading sd-inpainting-1.5:
webui-docker-invoke-1  | Downloading stable-diffusion-2.1-768:
webui-docker-invoke-1  | ** models.yaml exists. Renaming to models.yaml.orig
webui-docker-invoke-1  | Successfully created new configuration file /InvokeAI/configs/models.yaml
webui-docker-invoke-1  | 
webui-docker-invoke-1  | ** INVOKEAI INSTALLATION SUCCESSFUL **
webui-docker-invoke-1  | If you installed manually from source or with 'pip install': activate the virtual environment
webui-docker-invoke-1  | then run one of the following commands to start InvokeAI.
webui-docker-invoke-1  | 
webui-docker-invoke-1  | Web UI:
webui-docker-invoke-1  |    invokeai --web # (connect to http://localhost:9090)
webui-docker-invoke-1  |    invokeai --web --host 0.0.0.0 # (connect to http://your-lan-ip:9090 from another computer on the local network)
webui-docker-invoke-1  | 
webui-docker-invoke-1  | Command-line interface:
webui-docker-invoke-1  |    invokeai
webui-docker-invoke-1  | 
webui-docker-invoke-1  | If you installed using an installation script, run:
webui-docker-invoke-1  |   /InvokeAI/invoke.sh
webui-docker-invoke-1  | 
webui-docker-invoke-1  | Add the '--help' argument to see all of the command-line switches available for use.
webui-docker-invoke-1  | 
webui-docker-invoke-1  | * Initializing, be patient...
webui-docker-invoke-1  | >> Initialization file /InvokeAI/invokeai.init found. Loading...
webui-docker-invoke-1  | >> Internet connectivity is True
webui-docker-invoke-1  | >> InvokeAI, version 2.3.5.post2
webui-docker-invoke-1  | >> InvokeAI runtime directory is "/InvokeAI"
webui-docker-invoke-1  | >> GFPGAN Initialized
webui-docker-invoke-1  | >> CodeFormer Initialized
webui-docker-invoke-1  | >> ESRGAN Initialized
webui-docker-invoke-1  | >> Using device_type cuda
webui-docker-invoke-1  | >> CUDA device 'NVIDIA A100 80GB PCIe' (GPU 0)
webui-docker-invoke-1  | >> xformers memory-efficient attention is available and enabled
webui-docker-invoke-1  | >> NSFW checker is disabled
webui-docker-invoke-1  | >> Current VRAM usage:  0.00G
webui-docker-invoke-1  | >> Loading diffusers model from runwayml/stable-diffusion-v1-5
webui-docker-invoke-1  |    | Using faster float16 precision
webui-docker-invoke-1  |    | Loading diffusers VAE from stabilityai/sd-vae-ft-mse
webui-docker-invoke-1  |    | Default image dimensions = 512 x 512
webui-docker-invoke-1  | >> Model loaded in 7.70s
webui-docker-invoke-1  | >> Max VRAM used to load the model: 2.16G 
webui-docker-invoke-1  | >> Current VRAM usage:2.16G
webui-docker-invoke-1  | >> Loading embeddings from /data/embeddings/
webui-docker-invoke-1  | >> Textual inversion triggers: 
webui-docker-invoke-1  | >> Setting Sampler to k_lms (LMSDiscreteScheduler)
webui-docker-invoke-1  | 
webui-docker-invoke-1  | * --web was specified, starting web server...
webui-docker-invoke-1  | Traceback (most recent call last):
webui-docker-invoke-1  |   File "/opt/conda/bin/invokeai", line 8, in <module>
webui-docker-invoke-1  |     sys.exit(main())
webui-docker-invoke-1  |   File "/InvokeAI/ldm/invoke/CLI.py", line 184, in main
webui-docker-invoke-1  |     invoke_ai_web_server_loop(gen, gfpgan, codeformer, esrgan)
webui-docker-invoke-1  |   File "/InvokeAI/ldm/invoke/CLI.py", line 1078, in invoke_ai_web_server_loop
webui-docker-invoke-1  |     from invokeai.backend import InvokeAIWebServer
webui-docker-invoke-1  |   File "/InvokeAI/invokeai/backend/__init__.py", line 4, in <module>
webui-docker-invoke-1  |     from .invoke_ai_web_server import InvokeAIWebServer
webui-docker-invoke-1  |   File "/InvokeAI/invokeai/backend/invoke_ai_web_server.py", line 17, in <module>
webui-docker-invoke-1  |     from flask import Flask, redirect, send_from_directory, request, make_response
webui-docker-invoke-1  |   File "/opt/conda/lib/python3.10/site-packages/flask/__init__.py", line 7, in <module>
webui-docker-invoke-1  |     from .app import Flask as Flask
webui-docker-invoke-1  |   File "/opt/conda/lib/python3.10/site-packages/flask/app.py", line 27, in <module>
webui-docker-invoke-1  |     from . import cli
webui-docker-invoke-1  |   File "/opt/conda/lib/python3.10/site-packages/flask/cli.py", line 17, in <module>
webui-docker-invoke-1  |     from .helpers import get_debug_flag
webui-docker-invoke-1  |   File "/opt/conda/lib/python3.10/site-packages/flask/helpers.py", line 14, in <module>
webui-docker-invoke-1  |     from werkzeug.urls import url_quote
webui-docker-invoke-1  | ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/opt/conda/lib/python3.10/site-packages/werkzeug/urls.py)
webui-docker-invoke-1  | Exception ignored in atexit callback: <built-in function write_history_file>
webui-docker-invoke-1  | FileNotFoundError: [Errno 2] No such file or directory
webui-docker-invoke-1 exited with code 1

Hardware / Software

  • OS: Ubuntu 22.04
  • OS version: Ubuntu 22.04.3 LTS
  • Docker Version:
 Engine:
 Version:          24.0.6
 API version:      1.43 (minimum version 1.12)
 Go version:       go1.20.7
 Git commit:       1a79695
 Built:            Mon Sep  4 12:31:44 2023
 OS/Arch:          linux/amd64
 Experimental:     false
containerd:
 Version:          1.6.24
 GitCommit:        61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
runc:
 Version:          1.1.9
 GitCommit:        v1.1.9-0-gccaecfc
docker-init:
 Version:          0.19.0
 GitCommit:        de40ad0
  • Docker compose version: v2.21.0
  • Repo version: 8.1.0-5-g6a34739
  • RAM: 1TB
  • GPU/VRAM:
NVIDIA A100 80G
NVIDIA-SMI 525.125.06   Driver Version: 525.125.06   CUDA Version: 12.0

Steps to Reproduce 0. git clone this repo.

  1. docker compose --profile download up --build succeeded.
  2. models in /data were manually downloaded then.
  3. docker compose --profile invoke up --build triggered this error.

YuanfengZhang avatar Oct 20 '23 10:10 YuanfengZhang

As discussed on Internet before, it's caused by the Werkzeug version, but I cannot find any "Werkzeug" string in the whole repo.

I did fix it by add the following lines

RUN --mount=type=cache,target=/root/.cache/pip \
  pip uninstall -y Werkzeug && \
  pip install Werkzeug==2.3.6

(version number from https://github.com/TechXueXi/TechXueXi/issues/258#issuecomment-1752112966_) at https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/6a34739135eb112667f00943c1fac98ab294716a/services/invoke/Dockerfile#L41

But honestly I have no idea which version shall we use (Werkzeug latest=3.0.0), is there anyone can help?

YuanfengZhang avatar Oct 20 '23 11:10 YuanfengZhang

This should hopefully be fixed by #596 but it is tad more complicated than I thought.

AbdBarho avatar Nov 13 '23 20:11 AbdBarho