From 00d1eefebcc11d6efb25554926569c54ce76cc1a Mon Sep 17 00:00:00 2001 From: emranemran Date: Wed, 18 Dec 2024 08:46:40 +0000 Subject: [PATCH 1/2] docker/runner: add FasterLivePortrait initial changes --- runner/dl_checkpoints.sh | 47 ++++++++++++++-------- runner/docker/Dockerfile.live-base-comfyui | 6 +++ 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/runner/dl_checkpoints.sh b/runner/dl_checkpoints.sh index 24320503..7aa1dc07 100755 --- a/runner/dl_checkpoints.sh +++ b/runner/dl_checkpoints.sh @@ -87,12 +87,12 @@ function download_all_models() { function download_live_models() { huggingface-cli download KBlueLeaf/kohaku-v2.1 --include "*.safetensors" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models huggingface-cli download stabilityai/sd-turbo --include "*.safetensors" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models - huggingface-cli download warmshao/FasterLivePortrait --local-dir models/FasterLivePortrait--checkpoints huggingface-cli download microsoft/Florence-2-large --include "*.bin" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models/ComfyUI--models huggingface-cli download microsoft/Florence-2-large-ft --include "*.bin" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models/ComfyUI--models huggingface-cli download microsoft/Florence-2-base --include "*.bin" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models/ComfyUI--models huggingface-cli download microsoft/Florence-2-base-ft --include "*.bin" "*.json" "*.txt" --exclude ".onnx" ".onnx_data" --cache-dir models/ComfyUI--models huggingface-cli download yuvraj108c/Depth-Anything-Onnx --include depth_anything_vitl14.onnx --local-dir models/ComfyUI--models/Depth-Anything-Onnx + huggingface-cli download warmshao/FasterLivePortrait --local-dir models/ComfyUI--models/FasterLivePortrait--checkpoints download_sam2_checkpoints download_stream_diffusion_checkpoints download_stream_diffusion_loras @@ -138,29 +138,44 @@ function build_tensorrt_models() { done" # FasterLivePortrait - docker run --rm -v ./models:/models --gpus all -l TensorRT-engines \ - livepeer/ai-runner:live-app-liveportrait \ - bash -c "cd /app/app/live/FasterLivePortrait && \ - if [ ! -f '/models/FasterLivePortrait--checkpoints/liveportrait_onnx/stitching_lip.trt' ]; then + # docker run --rm -v ./models:/models --gpus all -l TensorRT-engines \ + # livepeer/ai-runner:live-app-liveportrait \ + # bash -c "cd /app/app/live/FasterLivePortrait && \ + # if [ ! -f '/models/FasterLivePortrait--checkpoints/liveportrait_onnx/stitching_lip.trt' ]; then + # echo 'Building TensorRT engines for LivePortrait models (regular)...' + # sh scripts/all_onnx2trt.sh + # else + # echo 'Regular LivePortrait TensorRT engines already exist, skipping build' + # fi && \ + # if [ ! -f '/models/FasterLivePortrait--checkpoints/liveportrait_animal_onnx/stitching_lip.trt' ]; then + # echo 'Building TensorRT engines for LivePortrait models (animal)...' + # sh scripts/all_onnx2trt_animal.sh + # else + # echo 'Animal LivePortrait TensorRT engines already exist, skipping build' + # fi" + + # ComfyUI (only DepthAnything for now) + docker run --rm -v ./models:/models --gpus all -l TensorRT-engines \ + livepeer/ai-runner:live-app-comfyui \ + bash -c "cd /comfyui/models/Depth-Anything-Onnx && \ + python /comfyui/custom_nodes/ComfyUI-Depth-Anything-Tensorrt/export_trt.py && \ + mkdir -p /comfyui/models/tensorrt/depth-anything && \ + mv *.engine /comfyui/models/tensorrt/depth-anything" \ + bash -c "cd /comfyui/models/FasterLivePortrait--checkpoints && \ + if [ ! -f 'liveportrait_onnx/stitching_lip.trt' ]; then echo 'Building TensorRT engines for LivePortrait models (regular)...' - sh scripts/all_onnx2trt.sh + sh /comfyui/custom_nodes/ComfyUI-FasterLivePortrait/FasterLivePortrait/scripts/all_onnx2trt.sh else echo 'Regular LivePortrait TensorRT engines already exist, skipping build' fi && \ - if [ ! -f '/models/FasterLivePortrait--checkpoints/liveportrait_animal_onnx/stitching_lip.trt' ]; then + if [ ! -f 'liveportrait_animal_onnx/stitching_lip.trt' ]; then echo 'Building TensorRT engines for LivePortrait models (animal)...' - sh scripts/all_onnx2trt_animal.sh + sh /comfyui/custom_nodes/ComfyUI-FasterLivePortrait/FasterLivePortrait/scripts/all_onnx2trt_animal.sh else echo 'Animal LivePortrait TensorRT engines already exist, skipping build' - fi" + fi \ + mv *.engine /comfyui/models/tensorrt/fasterliveportrait" - # ComfyUI (only DepthAnything for now) - docker run --rm -v ./models:/models --gpus all -l TensorRT-engines \ - livepeer/ai-runner:live-app-comfyui \ - bash -c "cd /comfyui/models/Depth-Anything-Onnx && \ - python /comfyui/custom_nodes/ComfyUI-Depth-Anything-Tensorrt/export_trt.py && \ - mkdir -p /comfyui/models/tensorrt/depth-anything && \ - mv *.engine /comfyui/models/tensorrt/depth-anything" } # Download models with a restrictive license. diff --git a/runner/docker/Dockerfile.live-base-comfyui b/runner/docker/Dockerfile.live-base-comfyui index 51413ef5..d1094d02 100644 --- a/runner/docker/Dockerfile.live-base-comfyui +++ b/runner/docker/Dockerfile.live-base-comfyui @@ -75,6 +75,12 @@ RUN cd /comfyui/custom_nodes && \ RUN cd /comfyui/custom_nodes && \ git clone https://github.com/tsogzark/ComfyUI-load-image-from-url.git +# Install ComfyUI-FasterLivePortrait (https://github.com/emranemran/ComfyUI-FasterLivePortrait) +RUN cd /comfyui/custom_nodes && \ + git clone https://github.com/emranemran/ComfyUI-FasterLivePortrait && \ + cd ComfyUI-FasterLivePortrait && \ + pip install -r requirements.txt + # Upgrade TensorRT to 10.6.0 RUN pip uninstall -y tensorrt && \ pip install tensorrt==10.6.0 From 75c1fb654e1e70fcfe05fb44f60b9a751576949c Mon Sep 17 00:00:00 2001 From: emranemran Date: Wed, 18 Dec 2024 23:38:55 +0000 Subject: [PATCH 2/2] wip --- runner/docker/Dockerfile.live-base-comfyui | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runner/docker/Dockerfile.live-base-comfyui b/runner/docker/Dockerfile.live-base-comfyui index d1094d02..355c35dd 100644 --- a/runner/docker/Dockerfile.live-base-comfyui +++ b/runner/docker/Dockerfile.live-base-comfyui @@ -80,6 +80,13 @@ RUN cd /comfyui/custom_nodes && \ git clone https://github.com/emranemran/ComfyUI-FasterLivePortrait && \ cd ComfyUI-FasterLivePortrait && \ pip install -r requirements.txt +RUN git clone https://github.com/SeanWangJS/grid-sample3d-trt-plugin.git /opt/grid-sample3d-trt-plugin && \ + cd /opt/grid-sample3d-trt-plugin && \ + sed -i 's/set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES ".*")/set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "60;70;75;80;86")/' CMakeLists.txt && \ + mkdir build && cd build && \ + export PATH=/usr/local/cuda/bin:$PATH && \ + cmake .. -DTensorRT_ROOT=/usr/include && \ + make # Upgrade TensorRT to 10.6.0 RUN pip uninstall -y tensorrt && \