update lambda packages version

pull/644/head
Jingyi 2024-04-05 15:27:29 +08:00
parent dff885cc16
commit 91c66d7766
14 changed files with 69 additions and 231 deletions

View File

@ -1,59 +0,0 @@
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:1.13.1-gpu-py39-cu117-ubuntu20.04-sagemaker
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:2.0.0-gpu-py310-cu118-ubuntu20.04-sagemaker
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:2.0.1-gpu-py310-cu118-ubuntu20.04-sagemaker
# FROM 727897471807.dkr.ecr.cn-north-1.amazonaws.com.cn/pytorch-training:2.0.1-gpu-py310-cu118-ubuntu20.04-sagemaker
FROM 727897471807.dkr.ecr.cn-northwest-1.amazonaws.com.cn/pytorch-training: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/
# install pkg lib for proprocess in controlnet
RUN apt-get install -y file && \
pip install --upgrade pip && \
apt-get install -y libtcmalloc-minimal4
# prepare environment fow webui
RUN pip install -r /opt/ml/code/requirements_versions.txt && \
pip install https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip && \
pip install https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip && \
pip install -U -I --no-deps xformers==0.0.20 && \
pip install ngrok
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
COPY inference/clip_init.py /opt/ml/code
RUN python /opt/ml/code/clip_init.py
RUN sed 's/bitsandbytes==0.35.4/bitsandbytes-cuda111==0.26.0.post2/' /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt > /tmp/requirements_modified.txt
RUN pip install -r /tmp/requirements_modified.txt && \
#pip install -r /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt && \
pip install -r /opt/ml/code/extensions/sd-webui-controlnet/requirements.txt && \
rm /tmp/requirements_modified.txt
RUN wget https://aws-gcr-solutions-us-east-1.s3.amazonaws.com/stable-diffusion-public-resources/dependencies/opencv_python-4.8.1.78-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl && \
pip install opencv_python-4.8.1.78-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
RUN pip install trash-cli
#RUN trash /opt/conda/lib/python3.10/site-packages/opencv_python*
WORKDIR /opt/ml/code
ENV TORCHDYNAMO_DISABLE 1
ENV SAGEMAKER_PROGRAM extensions/stable-diffusion-aws-extension/build_scripts/training/sagemaker_entrypoint_cn.py

View File

@ -1,38 +0,0 @@
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:1.13.1-gpu-py39-cu117-ubuntu20.04-sagemaker
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:2.0.0-gpu-py310-cu118-ubuntu20.04-sagemaker
FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training: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/
# install requirements for webui
# patch for opencv 4.7
# https://stackoverflow.com/questions/68886239/cannot-uninstall-numpy-1-21-2-record-file-not-found
RUN pip install trash-cli
RUN trash /opt/conda/lib/python3.10/site-packages/opencv_python*
RUN pip install -r /opt/ml/code/requirements.txt && pip install -r /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt \
&& pip install -r /opt/ml/code/extensions/sd-webui-controlnet/requirements.txt
RUN pip install torch==2.0.1
RUN pip uninstall -y torchvision
RUN pip install torchvision
RUN pip uninstall -y torchaudio
RUN pip install torchaudio
RUN pip install xformers
RUN pip install tensorflow==2.10
RUN pip install pydantic
RUN pip install safetensors
RUN pip install omegaconf
RUN rm /opt/ml/code/requirements.txt
WORKDIR /opt/ml/code
ENV TORCHDYNAMO_DISABLE 1
ENV SAGEMAKER_PROGRAM extensions/stable-diffusion-aws-extension/build_scripts/training/sagemaker_entrypoint.py

View File

@ -0,0 +1,49 @@
FROM public.ecr.aws/ubuntu/ubuntu:22.04_stable as builder
RUN apt-get update -y
RUN apt-get install -y wget
RUN wget https://github.com/peak/s5cmd/releases/download/v2.2.2/s5cmd_2.2.2_Linux-64bit.tar.gz
RUN tar xzvf s5cmd_2.2.2_Linux-64bit.tar.gz
FROM public.ecr.aws/ubuntu/ubuntu:22.04_stable
COPY --from=builder /s5cmd /usr/local/bin/
SHELL ["/bin/bash", "-c"]
RUN adduser --disabled-password --gecos '' ubuntu
RUN apt-get update -y && \
apt-get install --no-install-recommends -y git libgl1 libtcmalloc-minimal4 libglib2.0-0 python3.10 python3.10-venv net-tools bc && \
# may not needed in endpoint
apt-get install --no-install-recommends -y pkg-config file curl protobuf-compiler mesa-utils && \
# for env install
apt-get install --no-install-recommends -y tar python3-dev libcairo2-dev libprotobuf-dev build-essential cmake wget && \
# clean up
rm -rf /var/lib/apt/lists/*
RUN cd /home/ubuntu || exit 1 && \
curl -sSL "https://raw.githubusercontent.com/awslabs/stable-diffusion-aws-extension/dev/install_sd.sh" | bash
COPY inference/clip_init.py /home/ubuntu/stable-diffusion-webui
RUN cd /home/ubuntu/stable-diffusion-webui/ && \
source venv/bin/activate python && \
python3 /home/ubuntu/stable-diffusion-webui/clip_init.py && \
wget -O /home/ubuntu/stable-diffusion-webui/models/VAE-approx/vaeapprox-sdxl.pt https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/download/v1.0.0-pre/vaeapprox-sdxl.pt
RUN mkdir -p /home/ubuntu/conda/lib/ && \
cd /home/ubuntu/conda/lib/ && \
wget https://aws-gcr-solutions-us-west-2.s3.us-west-2.amazonaws.com/extension-for-stable-diffusion-on-aws/1.5.0-g5/conda/libcufft.so.10 && \
wget https://aws-gcr-solutions-us-west-2.s3.us-west-2.amazonaws.com/extension-for-stable-diffusion-on-aws/1.5.0-g5/conda/libcurand.so.10
WORKDIR /home/ubuntu/
ENV ON_DOCKER true
ENV FULL_IMAGE false
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4
COPY inference/serve.sh /
RUN chmod +x /serve.sh
ENTRYPOINT ["bash", "/serve.sh"]

View File

@ -26,9 +26,15 @@ RUN cd /home/ubuntu || exit 1 && \
curl -sSL "https://raw.githubusercontent.com/awslabs/stable-diffusion-aws-extension/dev/install_sd.sh" | bash curl -sSL "https://raw.githubusercontent.com/awslabs/stable-diffusion-aws-extension/dev/install_sd.sh" | bash
COPY inference/clip_init.py /home/ubuntu/stable-diffusion-webui COPY inference/clip_init.py /home/ubuntu/stable-diffusion-webui
RUN python /home/ubuntu/stable-diffusion-webui/clip_init.py RUN cd /home/ubuntu/stable-diffusion-webui/ && \
source venv/bin/activate python && \
python3 /home/ubuntu/stable-diffusion-webui/clip_init.py && \
wget -O /home/ubuntu/stable-diffusion-webui/models/VAE-approx/vaeapprox-sdxl.pt https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/download/v1.0.0-pre/vaeapprox-sdxl.pt
RUN wget -O /home/ubuntu/stable-diffusion-webui/models/VAE-approx/vaeapprox-sdxl.pt https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/download/v1.0.0-pre/vaeapprox-sdxl.pt RUN mkdir -p /home/ubuntu/conda/lib/ && \
cd /home/ubuntu/conda/lib/ && \
wget https://aws-gcr-solutions-us-west-2.s3.us-west-2.amazonaws.com/extension-for-stable-diffusion-on-aws/1.5.0-g5/conda/libcufft.so.10 && \
wget https://aws-gcr-solutions-us-west-2.s3.us-west-2.amazonaws.com/extension-for-stable-diffusion-on-aws/1.5.0-g5/conda/libcurand.so.10
WORKDIR /home/ubuntu/ WORKDIR /home/ubuntu/
@ -38,10 +44,6 @@ ENV FULL_IMAGE false
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4
COPY inference/serve.sh / COPY inference/serve.sh /
RUN chmod +x /serve.sh RUN chmod +x /serve.sh
COPY inference/cn_serve /home/ubuntu/stable-diffusion-webui/ ENTRYPOINT ["bash", "/serve.sh"]
ENTRYPOINT ["python", "/home/ubuntu/stable-diffusion-webui/cn_serve"]

View File

@ -22,6 +22,9 @@ RUN apt-get update -y && \
# clean up # clean up
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
COPY inference/metrics.py /
RUN chmod +x /metrics.py
WORKDIR /home/ubuntu/ WORKDIR /home/ubuntu/
ENV ON_DOCKER true ENV ON_DOCKER true
@ -30,9 +33,6 @@ ENV FULL_IMAGE false
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4
COPY inference/serve.sh / COPY inference/serve.sh /
COPY inference/metrics.py /
RUN chmod +x /serve.sh RUN chmod +x /serve.sh
RUN chmod +x /metrics.py
ENTRYPOINT ["bash", "/serve.sh"] ENTRYPOINT ["bash", "/serve.sh"]

View File

@ -1,65 +0,0 @@
# FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:2.0.1-cpu-py310-ubuntu20.04-sagemaker
# FROM 727897471807.dkr.ecr.cn-north-1.amazonaws.com.cn/pytorch-training:2.0.1-cpu-py310-ubuntu20.04-sagemaker
FROM 727897471807.dkr.ecr.cn-northwest-1.amazonaws.com.cn/pytorch-training:2.0.1-cpu-py310-ubuntu20.04-sagemaker
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 utils/cn_serve /opt/ml/code
# add accelerate
RUN mkdir -p /root/.cache/huggingface/accelerate
COPY utils/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/
RUN pip install --upgrade pip
# patch for opencv 4.7
# https://stackoverflow.com/questions/68886239/cannot-uninstall-numpy-1-21-2-record-file-not-found
RUN pip install trash-cli
RUN trash /opt/conda/lib/python3.10/site-packages/opencv_python*
RUN pip install -r /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt && \
pip install -r /opt/ml/code/extensions/sd-webui-controlnet/requirements.txt && \
pip install segment_anything && \
apt-get install -y google-perftools
# prepare environment fow webui
RUN pip install -r /opt/ml/code/requirements_versions.txt && \
pip install https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip && \
pip install https://github.com/mlfoundations/open_clip/archive/bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b.zip && \
pip install -U -I --no-deps xformers==0.0.20 && \
pip install ngrok
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
COPY inference/clip_init.py /opt/ml/code
RUN python /opt/ml/code/clip_init.py
WORKDIR /opt/ml/code
ENV ON_DOCKER true
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
ENTRYPOINT ["python", "/opt/ml/code/cn_serve"]

View File

@ -1,40 +0,0 @@
FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:2.0.1-cpu-py310-ubuntu20.04-sagemaker
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 utils/serve /opt/ml/code
# add accelerate
RUN mkdir -p /root/.cache/huggingface/accelerate
COPY utils/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/
RUN pip install --upgrade pip
# patch for opencv 4.7
# https://stackoverflow.com/questions/68886239/cannot-uninstall-numpy-1-21-2-record-file-not-found
RUN pip install trash-cli
RUN trash /opt/conda/lib/python3.10/site-packages/opencv_python*
RUN pip install -r /opt/ml/code/requirements.txt && pip install -r /opt/ml/code/extensions/sd_dreambooth_extension/requirements.txt \
&& pip install -r /opt/ml/code/extensions/sd-webui-controlnet/requirements.txt
WORKDIR /opt/ml/code
ENV ON_DOCKER true
# install libtcmalloc to solve memory leak for multi model switch
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/9323
RUN apt-get install -y google-perftools
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
ENTRYPOINT ["python", "/opt/ml/code/serve"]

View File

@ -19,12 +19,6 @@ accelerate launch --num_cpu_threads_per_process=6 launch.py --api
# How to build images # How to build images
### Build public images for aigc-webui-utils which is used for light-weight CPU operations, like create_model in merge_checkpoint.
```
sh build_and_push.sh Dockerfile.utils.from_scratch aigc-webui-utils
```
### Build public images for aigc-webui-inference which is used for GPU operations, like txt2img inference. ### Build public images for aigc-webui-inference which is used for GPU operations, like txt2img inference.
@ -33,12 +27,6 @@ sh build_and_push.sh Dockerfile.inference.from_scratch aigc-webui-inference
``` ```
### Build public images for aigc-webui-dreambooth-train which is used for training model in Dreambooth.
```
sh build_and_push.sh Dockerfile.dreambooth.from_scratch aigc-webui-dreambooth-training
```
### Update public ecr to your private ecr ### Update public ecr to your private ecr

View File

@ -13,5 +13,3 @@ then
echo "Usage: $0 <extension-branch> <image-tag> <commit_id>" echo "Usage: $0 <extension-branch> <image-tag> <commit_id>"
exit 1 exit 1
fi fi
#./build_and_push.sh Dockerfile.dreambooth.from_scratch aigc-webui-dreambooth-training $mode $tag $commit_id

View File

@ -16,6 +16,3 @@ fi
#./build_and_push.sh Dockerfile.inference.cn.from_scratch aigc-webui-inference $mode $tag $commit_id #./build_and_push.sh Dockerfile.inference.cn.from_scratch aigc-webui-inference $mode $tag $commit_id
#./build_and_push.sh Dockerfile.utils.cn.from_scratch aigc-webui-utils $mode $tag $commit_id
#./build_and_push.sh Dockerfile.dreambooth.cn.from_scratch aigc-webui-dreambooth-training $mode $tag $commit_id

View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
./build_and_push_local.sh Dockerfile.inference.cn.comfy.from_scratch esd-inference dev "comfy-cn"

View File

@ -343,6 +343,8 @@ comfy_launch_from_local(){
if [ "$FULL_IMAGE" == "true" ]; then if [ "$FULL_IMAGE" == "true" ]; then
echo "Running on full docker image..." echo "Running on full docker image..."
if [ "$SERVICE_TYPE" == "sd" ]; then if [ "$SERVICE_TYPE" == "sd" ]; then
export LD_LIBRARY_PATH=/home/ubuntu/conda/lib:$LD_LIBRARY_PATH
# wget -P /home/ubuntu/stable-diffusion-webui/models/Stable-diffusion/ https://aws-gcr-solutions.s3.cn-north-1.amazonaws.com.cn/stable-diffusion-aws-extension-github-mainline/models/v1-5-pruned-emaonly.safetensors
sd_accelerate_launch sd_accelerate_launch
else else
comfy_accelerate_launch comfy_accelerate_launch
@ -366,3 +368,5 @@ if [ "$SERVICE_TYPE" == "sd" ]; then
else else
comfy_launch_from_local comfy_launch_from_local
fi fi
# todo https://aws-gcr-solutions-us-west-2.s3.us-west-2.amazonaws.com/extension-for-stable-diffusion-on-aws/1.5.0-g5/creator/inswapper_128.onnx

View File

@ -62,7 +62,6 @@ phases:
- echo "BUILD VERSION is ${BUILD_VERSION}" - echo "BUILD VERSION is ${BUILD_VERSION}"
- echo "./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}" - echo "./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}"
- ./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION} - ./build_and_push_inference_private.sh Dockerfile.inference.from_scratch esd-inference dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}
# - ./build_and_push_training_private.sh Dockerfile.dreambooth.from_scratch esd-training dev ${REGION} ${BUILD_VERSION} ${CODEBUILD_RESOLVED_SOURCE_VERSION}
- unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN - unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
- set -x - set -x
@ -75,4 +74,4 @@ artifacts:
- sonar-project.properties - sonar-project.properties
- buildspec.yml - buildspec.yml
- CHANGELOG.md - CHANGELOG.md
- .cfnnag_* - .cfnnag_*