stable-diffusion-webui-docker
stable-diffusion-webui-docker copied to clipboard
ImportError: cannot import name 'TypeIs'
Hi,
I have error on command "docker compose --profile auto up --build"
ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
- OS: Windows 11
- OS version: 23H2 (OS Build 22631.3958)
- WSL version (if applicable): v2
- Docker Version: Docker Desktop 4.33.1, Client 20.10.13, Engine 27.1.1
- Docker compose version: v2.29.1-desktop.1
- Repo version: from master
Attaching to auto-1
auto-1 | /stable-diffusion-webui
auto-1 | total 772K
auto-1 | drwxr-xr-x 1 root root 4.0K Aug 12 19:09 .
auto-1 | drwxr-xr-x 1 root root 4.0K Aug 12 19:52 ..
auto-1 | -rw-r--r-- 1 root root 48 Aug 12 19:06 .eslintignore
auto-1 | -rw-r--r-- 1 root root 3.4K Aug 12 19:06 .eslintrc.js
auto-1 | drwxr-xr-x 8 root root 4.0K Aug 12 19:06 .git
auto-1 | -rw-r--r-- 1 root root 55 Aug 12 19:06 .git-blame-ignore-revs
auto-1 | drwxr-xr-x 4 root root 4.0K Aug 12 19:06 .github
auto-1 | -rw-r--r-- 1 root root 521 Aug 12 19:06 .gitignore
auto-1 | -rw-r--r-- 1 root root 119 Aug 12 19:06 .pylintrc
auto-1 | -rw-r--r-- 1 root root 84K Aug 12 19:06 CHANGELOG.md
auto-1 | -rw-r--r-- 1 root root 243 Aug 12 19:06 CITATION.cff
auto-1 | -rw-r--r-- 1 root root 657 Aug 12 19:06 CODEOWNERS
auto-1 | -rw-r--r-- 1 root root 35K Aug 12 19:06 LICENSE.txt
auto-1 | -rw-r--r-- 1 root root 13K Aug 12 19:06 README.md
auto-1 | -rw-r--r-- 1 root root 146 Aug 12 19:06 _typos.toml
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 configs
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 embeddings
auto-1 | -rw-r--r-- 1 root root 167 Aug 12 19:06 environment-wsl2.yaml
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 extensions
auto-1 | drwxr-xr-x 13 root root 4.0K Aug 12 19:06 extensions-builtin
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 html
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:09 interrogate
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 javascript
auto-1 | -rw-r--r-- 1 root root 1.3K Aug 12 19:06 launch.py
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 localizations
auto-1 | drwxr-xr-x 7 root root 4.0K Aug 12 19:06 models
auto-1 | drwxr-xr-x 7 root root 4.0K Aug 12 19:06 modules
auto-1 | -rw-r--r-- 1 root root 185 Aug 12 19:06 package.json
auto-1 | -rw-r--r-- 1 root root 841 Aug 12 19:06 pyproject.toml
auto-1 | drwxr-xr-x 8 root root 4.0K Aug 12 18:18 repositories
auto-1 | -rw-r--r-- 1 root root 49 Aug 12 19:06 requirements-test.txt
auto-1 | -rw-r--r-- 1 root root 371 Aug 12 19:06 requirements.txt
auto-1 | -rw-r--r-- 1 root root 42 Aug 12 19:06 requirements_npu.txt
auto-1 | -rw-r--r-- 1 root root 645 Aug 12 19:06 requirements_versions.txt
auto-1 | -rw-r--r-- 1 root root 411K Aug 12 19:06 screenshot.png
auto-1 | -rw-r--r-- 1 root root 6.1K Aug 12 19:06 script.js
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 scripts
auto-1 | -rw-r--r-- 1 root root 43K Aug 12 19:06 style.css
auto-1 | drwxr-xr-x 4 root root 4.0K Aug 12 19:06 test
auto-1 | drwxr-xr-x 2 root root 4.0K Aug 12 19:06 textual_inversion_templates
auto-1 | -rw-r--r-- 1 root root 670 Aug 12 19:06 webui-macos-env.sh
auto-1 | -rw-r--r-- 1 root root 84 Aug 12 19:06 webui-user.bat
auto-1 | -rw-r--r-- 1 root root 1.4K Aug 12 19:06 webui-user.sh
auto-1 | -rw-r--r-- 1 root root 2.3K Aug 12 19:06 webui.bat
auto-1 | -rw-r--r-- 1 root root 5.3K Aug 12 19:06 webui.py
auto-1 | -rwxr-xr-x 1 root root 11K Aug 12 19:06 webui.sh
auto-1 | Mounted .cache
auto-1 | Mounted config_states
auto-1 | mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer'
auto-1 | mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer/weights'
auto-1 | Mounted .cache
auto-1 | Mounted embeddings
auto-1 | Mounted config.json
auto-1 | Mounted models
auto-1 | Mounted styles.csv
auto-1 | Mounted ui-config.json
auto-1 | Mounted extensions
auto-1 | Installing extension dependencies (if any)
auto-1 | Traceback (most recent call last):
auto-1 | File "/stable-diffusion-webui/webui.py", line 13, in <module>
auto-1 | initialize.imports()
auto-1 | File "/stable-diffusion-webui/modules/initialize.py", line 23, in imports
auto-1 | import gradio # noqa: F401
auto-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
auto-1 | import gradio.components as components
auto-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/components/__init__.py", line 3, in <module>
auto-1 | from gradio.components.bar_plot import BarPlot
auto-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/components/bar_plot.py", line 7, in <module>
auto-1 | import altair as alt
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/__init__.py", line 650, in <module>
auto-1 | from altair.vegalite import *
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/__init__.py", line 2, in <module>
auto-1 | from .v5 import *
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/v5/__init__.py", line 2, in <module>
auto-1 | from altair.expr.core import datum
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/expr/__init__.py", line 7, in <module>
auto-1 | from altair.expr.core import ConstExpression, FunctionExpression
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/expr/core.py", line 6, in <module>
auto-1 | from altair.utils import SchemaBase
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/utils/__init__.py", line 15, in <module>
auto-1 | from .plugin_registry import PluginRegistry
auto-1 | File "/opt/conda/lib/python3.10/site-packages/altair/utils/plugin_registry.py", line 6, in <module>
auto-1 | from typing_extensions import TypeAliasType, TypeIs, TypeVar
auto-1 | ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
auto-1 exited with code 1
Same issue on Windows 10
I have the same error with profile auto under Debian. The build succeeded but container fails to start. Here is the full log:
/stable-diffusion-webui
total 772K
drwxr-xr-x 1 root root 4.0K Aug 12 20:48 .
drwxr-xr-x 1 root root 4.0K Aug 14 02:32 ..
-rw-r--r-- 1 root root 48 Aug 12 20:46 .eslintignore
-rw-r--r-- 1 root root 3.4K Aug 12 20:46 .eslintrc.js
drwxr-xr-x 8 root root 4.0K Aug 12 20:46 .git
-rw-r--r-- 1 root root 55 Aug 12 20:46 .git-blame-ignore-revs
drwxr-xr-x 4 root root 4.0K Aug 12 20:46 .github
-rw-r--r-- 1 root root 521 Aug 12 20:46 .gitignore
-rw-r--r-- 1 root root 119 Aug 12 20:46 .pylintrc
-rw-r--r-- 1 root root 84K Aug 12 20:46 CHANGELOG.md
-rw-r--r-- 1 root root 243 Aug 12 20:46 CITATION.cff
-rw-r--r-- 1 root root 657 Aug 12 20:46 CODEOWNERS
-rw-r--r-- 1 root root 35K Aug 12 20:46 LICENSE.txt
-rw-r--r-- 1 root root 13K Aug 12 20:46 README.md
-rw-r--r-- 1 root root 146 Aug 12 20:46 _typos.toml
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 configs
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 embeddings
-rw-r--r-- 1 root root 167 Aug 12 20:46 environment-wsl2.yaml
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 extensions
drwxr-xr-x 13 root root 4.0K Aug 12 20:46 extensions-builtin
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 html
drwxr-xr-x 2 root root 4.0K Aug 12 20:48 interrogate
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 javascript
-rw-r--r-- 1 root root 1.3K Aug 12 20:46 launch.py
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 localizations
drwxr-xr-x 7 root root 4.0K Aug 12 20:46 models
drwxr-xr-x 7 root root 4.0K Aug 12 20:46 modules
-rw-r--r-- 1 root root 185 Aug 12 20:46 package.json
-rw-r--r-- 1 root root 841 Aug 12 20:46 pyproject.toml
drwxr-xr-x 8 root root 4.0K Aug 12 20:41 repositories
-rw-r--r-- 1 root root 49 Aug 12 20:46 requirements-test.txt
-rw-r--r-- 1 root root 371 Aug 12 20:46 requirements.txt
-rw-r--r-- 1 root root 42 Aug 12 20:46 requirements_npu.txt
-rw-r--r-- 1 root root 645 Aug 12 20:46 requirements_versions.txt
-rw-r--r-- 1 root root 411K Aug 12 20:46 screenshot.png
-rw-r--r-- 1 root root 6.1K Aug 12 20:46 script.js
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 scripts
-rw-r--r-- 1 root root 43K Aug 12 20:46 style.css
drwxr-xr-x 4 root root 4.0K Aug 12 20:46 test
drwxr-xr-x 2 root root 4.0K Aug 12 20:46 textual_inversion_templates
-rw-r--r-- 1 root root 670 Aug 12 20:46 webui-macos-env.sh
-rw-r--r-- 1 root root 84 Aug 12 20:46 webui-user.bat
-rw-r--r-- 1 root root 1.4K Aug 12 20:46 webui-user.sh
-rw-r--r-- 1 root root 2.3K Aug 12 20:46 webui.bat
-rw-r--r-- 1 root root 5.3K Aug 12 20:46 webui.py
-rwxr-xr-x 1 root root 11K Aug 12 20:46 webui.sh
Mounted .cache
Mounted config_states
mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer'
mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer/weights'
Mounted .cache
Mounted embeddings
Mounted config.json
Mounted models
Mounted styles.csv
Mounted ui-config.json
Mounted extensions
Installing extension dependencies (if any)
Traceback (most recent call last):
File "/stable-diffusion-webui/webui.py", line 13, in <module>
initialize.imports()
File "/stable-diffusion-webui/modules/initialize.py", line 23, in imports
import gradio # noqa: F401
File "/opt/conda/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
import gradio.components as components
File "/opt/conda/lib/python3.10/site-packages/gradio/components/__init__.py", line 3, in <module>
from gradio.components.bar_plot import BarPlot
File "/opt/conda/lib/python3.10/site-packages/gradio/components/bar_plot.py", line 7, in <module>
import altair as alt
File "/opt/conda/lib/python3.10/site-packages/altair/__init__.py", line 650, in <module>
from altair.vegalite import *
File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/__init__.py", line 2, in <module>
from .v5 import *
File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/v5/__init__.py", line 2, in <module>
from altair.expr.core import datum
File "/opt/conda/lib/python3.10/site-packages/altair/expr/__init__.py", line 7, in <module>
from altair.expr.core import ConstExpression, FunctionExpression
File "/opt/conda/lib/python3.10/site-packages/altair/expr/core.py", line 6, in <module>
from altair.utils import SchemaBase
File "/opt/conda/lib/python3.10/site-packages/altair/utils/__init__.py", line 15, in <module>
from .plugin_registry import PluginRegistry
File "/opt/conda/lib/python3.10/site-packages/altair/utils/plugin_registry.py", line 6, in <module>
from typing_extensions import TypeAliasType, TypeIs, TypeVar
ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
Here's my investigation of the issue:
- The problem is caused by altair update to v5.4.0, where higher requirement of
typing_extensions>=4.10.0is introduced (previously it was `typing_extensions>=4.0.1) - I further investigate the current packages installed in the container, there are two duplicated versions of
tying_extensions, wheretyping_extensions.pybelongs to version4.9.0, and that's the version actually resolved. This is whyaltaircannot find its newTypeIsexport.
drwxr-xr-x 2 root root 4096 Apr 24 16:17 typing_extensions-4.11.0.dist-info/
drwxr-xr-x 2 root root 4096 Apr 24 16:22 typing_extensions-4.9.0.dist-info/
-rw-r--r-- 2 root root 110125 Jan 18 2024 typing_extensions.py
-
I start looking for where the duplicated packages got installed, and found that a fresh container from
pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtimealready has these duplicated packages. I doubt thattyping_extensions==4.9.0comes withconda, but further investigation is needed. Hope someone can continue from here. -
A workaround for this seems to be uninstalling all
typing_extensionsand reinstalltyping_extensions==4.11.0in the docker file. Need someone to confirm if this is a good solution.
Here's my investigation of the issue:
- The problem is caused by altair update to v5.4.0, where higher requirement of
typing_extensions>=4.10.0is introduced (previously it was `typing_extensions>=4.0.1)- I further investigate the current packages installed in the container, there are two duplicated versions of
tying_extensions, wheretyping_extensions.pybelongs to version4.9.0, and that's the version actually resolved. This is whyaltaircannot find its newTypeIsexport.drwxr-xr-x 2 root root 4096 Apr 24 16:17 typing_extensions-4.11.0.dist-info/ drwxr-xr-x 2 root root 4096 Apr 24 16:22 typing_extensions-4.9.0.dist-info/ -rw-r--r-- 2 root root 110125 Jan 18 2024 typing_extensions.py
- I start looking for where the duplicated packages got installed, and found that a fresh container from
pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtimealready has these duplicated packages. I doubt thattyping_extensions==4.9.0comes withconda, but further investigation is needed. Hope someone can continue from here.- A workaround for this seems to be uninstalling all
typing_extensionsand reinstalltyping_extensions==4.11.0in the docker file. Need someone to confirm if this is a good solution.
Can you share your revised Dockerfile? Or where you are putting typing_extensions==4.11.0
I inserted it in this line of the Dockerfile and it is working in my environment.
https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/services/AUTOMATIC1111/Dockerfile#L41
Inserted are the following
RUN --mount=type=cache,target=/root/.cache/pip \
pip uninstall -y typing_extensions && \
pip install typing_extensions==4.11.0
The suggestion by @yasu-nxt worked for me.
RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
RUN --mount=type=cache,target=/root/.cache/pip \
pip uninstall -y typing_extensions && \
pip install typing_extensions==4.11.0
RUN --mount=type=cache,target=/root/.cache/pip \
pip install pyngrok xformers==0.0.26.post1 \
git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 \
git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 \
git+https://github.com/mlfoundations/[email protected]```
I inserted it in this line of the Dockerfile and it is working in my environment.
https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/services/AUTOMATIC1111/Dockerfile#L41
Inserted are the following
RUN --mount=type=cache,target=/root/.cache/pip \ pip uninstall -y typing_extensions && \ pip install typing_extensions==4.11.0
This worked for me too.
Using Ubuntu.
RUN --mount=type=cache,target=/root/.cache/pip
pip uninstall -y typing_extensions &&
pip install typing_extensions==4.11.0
this works for me too. Thanks!
Works for me too! Ubuntu 22.04
Confirmed fixed in debian 12.1
Confirmed fixed in ubuntu 22.04
I inserted it in this line of the Dockerfile and it is working in my environment. https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/services/AUTOMATIC1111/Dockerfile#L41 Inserted are the following
RUN --mount=type=cache,target=/root/.cache/pip \ pip uninstall -y typing_extensions && \ pip install typing_extensions==4.11.0This worked for me too.
Using Ubuntu.
Confirmed fixed in Windows Docker Desktop 4.31.1 (WSL2)
i fixed this by adding
# Add this line to update typing_extensions
RUN pip install --upgrade typing_extensions
Identical tickets : #722 , #729 , #742
Good practice alert !! 👉 Rather than installing typing_extensions at the Dockerfile level, it should be added to the requirements.txt file !!
It works for me if I pull the repository, edit the dockerfile and then launch using docker from the command line.
Has anyone gotten this working in Portainer? I found an example in a post here on how to add this as a stack in Portainer here but I get this same error when I try to launch AUTOMATIC1111, but I have no idea how I would apply the fix to the configuration.
I tried changing the "build: ..." line for the auto service to be the path where I cloned the repo (/home/username/stable-diffusion-webui-docker/services/AUTOMATIC1111) but when I tried to run it I still got the same error.
I tried changing the "build: ..." line for the auto service to be the path where I cloned the repo (/home/username/stable-diffusion-webui-docker/services/AUTOMATIC1111) but when I tried to run it I still got the same error.
I browsed to the container in the Portainer interface, clicked the Duplicate/Edit button, scrolled down and changed the command to: '/bin/sh' '-c' 'pip install --upgrade typing-extensions && python -u webui.py --listen --port 7860 ${CLI_ARGS}'
and redeployed. It runs for now.
I get the error:
[+] Building 0.0s (0/1) docker:default [+] Running 0/0 [+] Building 0.1s (1/1) FINISHED docker:default => [auto internal] load build definition from Dockerfile 0.0s [+] Running 0/1ring dockerfile: 3.00kB 0.0s ⠙ Service auto Building 0.1s failed to solve: dockerfile parse error on line 35: unknown instruction: pip
when trying this method but I have PIP installed
here is my dockerfile:
`RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git 6f7db241d2f8ba7457bac5ca9753331f0c266917
RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf
&& rm -rf assets data//*.png data//.jpg data/**/.gif
RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9 RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9 RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
RUN --mount=type=cache,target=/var/cache/apt
apt-get update && \
we need those
apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 \
extensions needs those
ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
WORKDIR /
RUN --mount=type=cache,target=/root/.cache/pip
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git &&
cd stable-diffusion-webui &&
git reset --hard v1.9.4 &&
pip install -r requirements_versions.txt
pip install --upgrade typing-extensions
ENV ROOT=/stable-diffusion-webui
COPY --from=download /repositories/ ${ROOT}/repositories/ RUN mkdir ${ROOT}/interrogate && cp ${ROOT}/repositories/clip-interrogator/clip_interrogator/data/* ${ROOT}/interrogate
RUN --mount=type=cache,target=/root/.cache/pip
pip install pyngrok xformers==0.0.26.post1
git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1
git+https://github.com/mlfoundations/[email protected]
there seems to be a memory leak (or maybe just memory not being freed fast enough) that is fixed by this version of malloc
maybe move this up to the dependencies list.
RUN apt-get -y install libgoogle-perftools-dev && apt-get clean ENV LD_PRELOAD=libtcmalloc.so
COPY . /docker
RUN \
mv ${ROOT}/style.css ${ROOT}/user.css && \
one of the ugliest hacks I ever wrote \
sed -i 's/in_app_dir = ./in_app_dir = True/g' /opt/conda/lib/python3.10/site-packages/gradio/routes.py &&
git config --global --add safe.directory ''
WORKDIR ${ROOT} ENV NVIDIA_VISIBLE_DEVICES=all ENV CLI_ARGS="" EXPOSE 7860 ENTRYPOINT ["/docker/entrypoint.sh"] CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}
`
I inserted it in this line of the Dockerfile and it is working in my environment. https://github.com/AbdBarho/stable-diffusion-webui-docker/blob/master/services/AUTOMATIC1111/Dockerfile#L41 Inserted are the following RUN --mount=type=cache,target=/root/.cache/pip
pip uninstall -y typing_extensions &&
pip install typing_extensions==4.11.0This worked for me too.
Using Ubuntu.
It works perfectly now in Ubuntu 24.04
The solution by yasu-nxt worked for me. I inserted on line 41.
Worked for me as well. Great, thanx @yasu-nxt !