FROM 727897471807.dkr.ecr.cn-northwest-1.amazonaws.com.cn/pytorch-inference:2.0.1-gpu-py310-cu118-ubuntu20.04-sagemaker # update environment RUN apt-get update -y # install pkg lib for proprocess in controlnet RUN apt-get install -y pkg-config RUN apt-get install -y libcairo2-dev COPY stable-diffusion-webui /opt/ml/code/ COPY inference/cn_serve /opt/ml/code # add accelerate RUN mkdir -p /root/.cache/huggingface/accelerate COPY inference/default_config.yaml /root/.cache/huggingface/accelerate/ # download s5cmd RUN mkdir -p /opt/ml/code/tools RUN wget https://github.com/peak/s5cmd/releases/download/v2.0.0/s5cmd_2.0.0_Linux-64bit.tar.gz -O /opt/ml/code/tools/s5cmd_2.0.0_Linux-64bit.tar.gz RUN tar xzvf /opt/ml/code/tools/s5cmd_2.0.0_Linux-64bit.tar.gz -C /opt/ml/code/tools/ # install pkg lib for proprocess in controlnet RUN apt-get install -y file && \ pip install --upgrade pip && \ pip install accelerate==0.19.0 && \ pip install deepspeed==0.9.5 && \ apt-get install -y libtcmalloc-minimal4 # prepare environment fow webui RUN pip install -r /opt/ml/code/requirements_versions.txt RUN mkdir /opt/ml/code/repositories RUN git clone https://github.com/Stability-AI/stablediffusion.git /opt/ml/code/repositories/stable-diffusion-stability-ai && \ git -C /opt/ml/code/repositories/stable-diffusion-stability-ai checkout cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf && \ git clone https://github.com/Stability-AI/generative-models.git /opt/ml/code/repositories/generative-models && \ git -C /opt/ml/code/repositories/generative-models checkout 45c443b316737a4ab6e40413d7794a7f5657c19f && \ git clone https://github.com/crowsonkb/k-diffusion.git /opt/ml/code/repositories/k-diffusion && \ git -C /opt/ml/code/repositories/k-diffusion checkout ab527a9a6d347f364e3d185ba6d714e22d80cb3c && \ git clone https://github.com/sczhou/CodeFormer.git /opt/ml/code/repositories/CodeFormer && \ git -C /opt/ml/code/repositories/CodeFormer checkout c5b4593074ba6214284d6acd5f1719b6c5d739af && \ git clone https://github.com/salesforce/BLIP.git /opt/ml/code/repositories/BLIP && \ git -C /opt/ml/code/repositories/BLIP checkout 48211a1594f1321b00f14c9f7a5b4813144b2fb9 && \ pip install -r /opt/ml/code/repositories/CodeFormer/requirements.txt RUN wget -O /opt/ml/code/models/VAE-approx/vaeapprox-sdxl.pt https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/download/v1.0.0-pre/vaeapprox-sdxl.pt RUN pip install -r /opt/ml/code/extensions/sd-webui-controlnet/requirements.txt && \ pip install -r /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt && \ pip install segment_anything && \ pip install nest-asyncio && \ pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118 && \ pip install https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip && \ pip install https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip RUN pip install open-clip-torch==2.20.0 COPY inference/clip_init.py /opt/ml/code RUN python /opt/ml/code/clip_init.py RUN pip install ngrok RUN wget https://aws-gcr-solutions-us-east-1.s3.amazonaws.com/stable-diffusion-public-resources/dependencies/xformers-0.0.20%2B1dc3d7a.d20231218-cp310-cp310-linux_x86_64.whl && \ pip install xformers-0.0.20+1dc3d7a.d20231218-cp310-cp310-linux_x86_64.whl RUN pip install trash-cli && \ trash /opt/conda/lib/python3.10/site-packages/opencv_python* RUN echo "/opt/ml/code" > "/opt/conda/lib/python3.10/site-packages/packages.pth" WORKDIR /opt/ml/code ENV ON_DOCKER true ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 ENTRYPOINT ["python", "/opt/ml/code/cn_serve"]