From b8f4e584637cc1eea3d412357a45d02ac87b07ce Mon Sep 17 00:00:00 2001 From: Kasisnu <5044120+kasisnu@users.noreply.github.com> Date: Mon, 15 Jul 2024 21:48:35 +0530 Subject: [PATCH] previews: add moviepy dependency back --- workflows/comfy/Dockerfile | 15 +++---- workflows/preview_server/Dockerfile | 40 +++++++++---------- workflows/preview_server/preview_server.py | 2 +- .../preview_server/server_requirements.txt | 3 +- 4 files changed, 27 insertions(+), 33 deletions(-) diff --git a/workflows/comfy/Dockerfile b/workflows/comfy/Dockerfile index 0d62bc2..e8c6ede 100644 --- a/workflows/comfy/Dockerfile +++ b/workflows/comfy/Dockerfile @@ -1,22 +1,17 @@ - -# NB(bt, 2022-12-12): The version of containerized CUDA must match (or be less than?) that of the host system running this container. -# Juggling these dependencies, plus the underlying Ubuntu system (which controls Python versions), is tricky. -# Nvidia does not provide a CUDA 11.6 with Ubuntu 22.04, which mirrors my own desktop machine. Their CUDA 11.6 + Ubuntu 20.04 image has -# a stale Python (3.8), so we have to use the DeadSnakes PPA to install a more modern version. -# Gross. FROM nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 +ARG COMFY_GIT_URL=https://github.com/comfyanonymous/ComfyUI.git +ARG COMFY_GIT_SHA=ece5acb8e8025d8ca26aa880f604d971d245475d + # See: https://github.com/opencontainers/image-spec/blob/master/annotations.md -LABEL org.opencontainers.image.title='Storyteller ML: Voice Conversion' -LABEL org.opencontainers.image.authors='adrien@storyteller.ai' +LABEL org.opencontainers.image.title='Storyteller ML: Studio Runners' +LABEL org.opencontainers.image.authors='kasisnu@storyteller.ai' # tzdata install hangs without presetting the time zone ENV TZ=UTC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Needed to install "future" release of Python 3.10 under Ubuntu 20.04, which only natively packages Python 3.8. -# We seem to be stuck on Ubuntu 22.04 because containerizd CUDA 11.6 is the only version we can run on my host machine, -# and Nvidia does not supply a (CUDA 11.6, Ubuntu 22.04) docker base image. RUN apt-get update \ && apt install software-properties-common -y \ && add-apt-repository ppa:deadsnakes/ppa diff --git a/workflows/preview_server/Dockerfile b/workflows/preview_server/Dockerfile index a8801dd..abc7d10 100644 --- a/workflows/preview_server/Dockerfile +++ b/workflows/preview_server/Dockerfile @@ -1,22 +1,17 @@ - -# NB(bt, 2022-12-12): The version of containerized CUDA must match (or be less than?) that of the host system running this container. -# Juggling these dependencies, plus the underlying Ubuntu system (which controls Python versions), is tricky. -# Nvidia does not provide a CUDA 11.6 with Ubuntu 22.04, which mirrors my own desktop machine. Their CUDA 11.6 + Ubuntu 20.04 image has -# a stale Python (3.8), so we have to use the DeadSnakes PPA to install a more modern version. -# Gross. FROM nvidia/cuda:12.2.2-cudnn8-devel-ubuntu22.04 +ARG COMFY_GIT_URL=https://github.com/comfyanonymous/ComfyUI.git +ARG COMFY_GIT_SHA=faa57430b0ff882275b1afcf6610e8e9f8a5929b + # See: https://github.com/opencontainers/image-spec/blob/master/annotations.md -LABEL org.opencontainers.image.title='Storyteller ML: Voice Conversion' -LABEL org.opencontainers.image.authors='adrien@storyteller.ai' +LABEL org.opencontainers.image.title='Storyteller ML: Studio Runners' +LABEL org.opencontainers.image.authors='kasisnu@storyteller.ai' # tzdata install hangs without presetting the time zone ENV TZ=UTC RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # Needed to install "future" release of Python 3.10 under Ubuntu 20.04, which only natively packages Python 3.8. -# We seem to be stuck on Ubuntu 22.04 because containerizd CUDA 11.6 is the only version we can run on my host machine, -# and Nvidia does not supply a (CUDA 11.6, Ubuntu 22.04) docker base image. RUN apt-get update \ && apt install software-properties-common -y \ && add-apt-repository ppa:deadsnakes/ppa @@ -30,6 +25,7 @@ RUN apt-get update \ python3-pip \ python3.10 \ python3.10-venv \ + python3.10-dev \ unzip \ htop \ vim \ @@ -54,34 +50,36 @@ RUN cd /tmp && \ RUN mkdir -p /root/.config/pip COPY ./pip.conf /root/.config/pip/pip.conf -WORKDIR /app # Copy files to container -COPY --chown=appuser:appgroup install.py /app/install.py -RUN chmod -R 777 /app +USER appuser +WORKDIR /app +COPY install.py /app/install.py +# download & install comfy ui and its dependencies +RUN python3 install.py --comfy-ui-url ${COMFY_GIT_URL} --comfy-ui-commit ${COMFY_GIT_SHA} -RUN python3 install.py --comfy-ui-url https://github.com/comfyanonymous/ComfyUI.git --comfy-ui-commit faa57430b0ff882275b1afcf6610e8e9f8a5929b RUN python3 -m venv venv RUN venv/bin/python -m pip install -r ComfyUI/requirements.txt --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ && \ venv/bin/python -m pip cache purge -COPY --chown=appuser:appgroup required_requirements.txt /app/required_requirements.txt +COPY required_requirements.txt /app/required_requirements.txt RUN venv/bin/python -m pip install -r required_requirements.txt --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ && \ venv/bin/python -m pip uninstall onnxruntime onnxruntime-gpu -y && \ venv/bin/python -m pip install onnxruntime-gpu==1.17.1 ort-nightly-gpu --index-url=https://pkgs.dev.azure.com/onnxruntime/onnxruntime/_packaging/onnxruntime-cuda-12/pypi/simple/ --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ && \ venv/bin/python -m pip cache purge -COPY --chown=appuser:appgroup repos.json /app/repos.json +COPY repos.json /app/repos.json RUN python3 install.py --repos-json repos.json -COPY --chown=appuser:appgroup dependencies.json /app/dependencies.json -COPY --chown=appuser:appgroup preview_server.py /app/preview_server.py -COPY --chown=appuser:appgroup server_requirements.txt /app/server_requirements.txt -COPY --chown=appuser:appgroup initialize_comfy_extensions.py /app/initialize_comfy_extensions.py +COPY dependencies.json /app/dependencies.json +COPY preview_server.py /app/preview_server.py +COPY server_requirements.txt /app/server_requirements.txt +COPY initialize_comfy_extensions.py /app/initialize_comfy_extensions.py ENV COMFY_ROOT_DIRECTORY=/app/ComfyUI ENV V2V_WORKFLOWS_DIRECTORY=/workflow_configs - +#TODO(kasisnu, 15/07/2024): remove root user after confirming that it is not needed anymore +USER root # protobuf use python implementation (weird error without) ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python \ No newline at end of file diff --git a/workflows/preview_server/preview_server.py b/workflows/preview_server/preview_server.py index a1bf654..a6b73da 100644 --- a/workflows/preview_server/preview_server.py +++ b/workflows/preview_server/preview_server.py @@ -10,7 +10,7 @@ import json import random from typing import Dict, Any, Optional import mimetypes - +from moviepy.editor import ImageClip from fastapi import FastAPI, File, UploadFile, HTTPException, Form, Request, Response import requests from jsonpath_ng import jsonpath, parse diff --git a/workflows/preview_server/server_requirements.txt b/workflows/preview_server/server_requirements.txt index 16ff43f..27cef1a 100644 --- a/workflows/preview_server/server_requirements.txt +++ b/workflows/preview_server/server_requirements.txt @@ -4,4 +4,5 @@ fastapi~=0.110.0 python-multipart~=0.0.9 pydantic~=2.6.4 jsonpath-ng~=1.6.1 -websockets \ No newline at end of file +websockets==12.0 +moviepy==1.0.3 \ No newline at end of file