Spaces:
Running
on
A10G
Running
on
A10G
| # Use a smaller base image if possible, but maintain CUDA compatibility | |
| FROM nvidia/cuda:11.7.1-base-ubuntu22.04 AS base | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Create user and directories early to leverage caching | |
| RUN adduser --disabled-password --gecos '' user && \ | |
| mkdir -p /content && \ | |
| chown -R user:user /content | |
| # Install system dependencies efficiently | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends \ | |
| libgl1 libglib2.0-0 wget git git-lfs python3-pip python-is-python3 && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Switch to user after system setup | |
| WORKDIR /content | |
| USER user | |
| # Combine pip installations into a single layer | |
| RUN pip3 install --upgrade pip==23.3.1 && \ | |
| pip install --no-cache-dir \ | |
| torchmetrics==0.11.4 \ | |
| numexpr \ | |
| httpx==0.24.1 \ | |
| pytorch_lightning==1.7.6 \ | |
| https://github.com/camenduru/stable-diffusion-webui-colab/releases/download/0.0.16/xformers-0.0.16+814314d.d20230119.A10G-cp310-cp310-linux_x86_64.whl \ | |
| --pre triton | |
| # Clone repository and apply patches in a single step | |
| RUN rm -rf stable-diffusion-webui && \ | |
| git clone -b v1.6 https://github.com/camenduru/stable-diffusion-webui && \ | |
| cd stable-diffusion-webui && \ | |
| sed -i 's/dict()))/dict())).cuda()/g' repositories/stable-diffusion-stability-ai/ldm/util.py && \ | |
| sed -i '/prepare_environment()/a os.system("sed -i -e '\''s/dict()))/dict())).cuda()/g'\'' repositories/stable-diffusion-stability-ai/ldm/util.py")' launch.py && \ | |
| sed -i 's/start()/#start()/g' launch.py && \ | |
| echo "fastapi==0.90.0" >> requirements_versions.txt && \ | |
| python launch.py --skip-torch-cuda-test | |
| # Add Model | |
| ADD --chown=user https://huggingface.co/darkstorm2150/OpenGen/resolve/main/OpenGen%20v1.0.safetensors /content/stable-diffusion-webui/models/Stable-diffusion/OpenGen%20v1.0.safetensors | |
| EXPOSE 7860 | |
| CMD ["python", "webui.py", "--xformers", "--listen", "--disable-console-progressbars", "--enable-console-prompts", "--no-progressbar-hiding", "--ui-config-file", "/content/shared-ui-config.json", "--ui-settings-file", "/content/shared-config.json"] |