Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker/runner: add FasterLivePortrait initial changes #373

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions runner/dl_checkpoints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 13 additions & 0 deletions runner/docker/Dockerfile.live-base-comfyui
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ 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
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 && \
pip install tensorrt==10.6.0
Expand Down