diff --git a/Dockerfile b/Dockerfile index ca7f05ee..50718fcf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,7 +54,7 @@ COPY benchmark benchmark COPY router router COPY backends backends COPY launcher launcher -RUN cargo build --profile release-opt --frozen +RUN cargo build --profile release-opt --frozen --features video # Python builder # Adapted from: https://github.com/pytorch/pytorch/blob/master/Dockerfile diff --git a/Dockerfile_amd b/Dockerfile_amd index 5b7f6931..dc748f49 100644 --- a/Dockerfile_amd +++ b/Dockerfile_amd @@ -18,18 +18,7 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - python3.11-dev \ - ffmpeg \ - libavcodec-dev \ - libavfilter-dev \ - libavdevice-dev \ - libavformat-dev \ - libavutil-dev \ - libswscale-dev \ - pkg-config \ - libclang-dev \ - clang - + python3.11-dev RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \ curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/$PROTOC_ZIP && \ unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \ @@ -330,10 +319,6 @@ COPY --from=builder /usr/src/target/release-opt/text-generation-router /usr/loca COPY --from=builder /usr/src/target/release-opt/text-generation-launcher /usr/local/bin/text-generation-launcher ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/conda/lib/" -# Copy the ffmpeg libraries -COPY --from=builder /usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu-copy/ -ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu-copy" - # AWS Sagemaker compatible image FROM base AS sagemaker diff --git a/Dockerfile_intel b/Dockerfile_intel index 4426e8eb..720d7bee 100644 --- a/Dockerfile_intel +++ b/Dockerfile_intel @@ -19,18 +19,7 @@ RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - python3.11-dev \ - ffmpeg \ - libavcodec-dev \ - libavfilter-dev \ - libavdevice-dev \ - libavformat-dev \ - libavutil-dev \ - libswscale-dev \ - pkg-config \ - libclang-dev \ - clang - + python3.11-dev RUN PROTOC_ZIP=protoc-21.12-linux-x86_64.zip && \ curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v21.12/$PROTOC_ZIP && \ unzip -o $PROTOC_ZIP -d /usr/local bin/protoc && \ @@ -232,10 +221,6 @@ COPY --from=builder /usr/src/target/release-opt/text-generation-router /usr/loca # Install launcher COPY --from=builder /usr/src/target/release-opt/text-generation-launcher /usr/local/bin/text-generation-launcher -# Copy the ffmpeg libraries -COPY --from=builder /usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu-copy/ -ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu-copy" - FROM ${PLATFORM} AS final ENV ATTENTION=paged ENV PREFIX_CACHING=0 diff --git a/Dockerfile_trtllm b/Dockerfile_trtllm index 4b2cccc7..b4523ea5 100644 --- a/Dockerfile_trtllm +++ b/Dockerfile_trtllm @@ -25,13 +25,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ libssl-dev \ libucx-dev \ ninja-build \ - ffmpeg \ - libavcodec-dev \ - libavfilter-dev \ - libavdevice-dev \ - libavformat-dev \ - libavutil-dev \ - libswscale-dev \ pkg-config \ pipx \ python3 \ @@ -110,9 +103,6 @@ COPY --from=mpi-builder /usr/local/mpi /usr/local/mpi COPY --from=trt-builder /usr/local/tensorrt /usr/local/tensorrt COPY --from=tgi-builder /usr/local/tgi /usr/local/tgi COPY --from=tgi-builder /usr/src/text-generation-inference/target/release/text-generation-backends-trtllm /usr/local/tgi/bin/text-generation-launcher -# Copy the ffmpeg libraries -COPY --from=cuda-builder /usr/lib/x86_64-linux-gnu/* /usr/lib/x86_64-linux-gnu-copy/ -ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu-copy" FROM runtime diff --git a/router/Cargo.toml b/router/Cargo.toml index c98db86f..36adf79c 100644 --- a/router/Cargo.toml +++ b/router/Cargo.toml @@ -77,3 +77,4 @@ default = ["ngrok"] ngrok = ["dep:ngrok"] google = [] kserve = [] +video = [] diff --git a/router/src/validation.rs b/router/src/validation.rs index 9fa8262d..a3775b17 100644 --- a/router/src/validation.rs +++ b/router/src/validation.rs @@ -22,9 +22,14 @@ use tokio::sync::oneshot; use tracing::{instrument, Span}; use {once_cell::sync::Lazy, regex::Regex}; // video processing -use ffmpeg_next::format::Pixel; -use ffmpeg_next::media::Type; -use ffmpeg_next::software::scaling::{context::Context, flag::Flags}; + +#[cfg(feature = "video")] +use ffmpeg_next::{ + format::Pixel, + media::Type, + software::scaling::{context::Context, flag::Flags}, +}; +#[cfg(feature = "video")] use std::io::Write; static DEFAULT_GENERATION_LENGTH: u32 = 1024; @@ -541,6 +546,16 @@ fn format_to_mimetype(format: ImageFormat) -> String { .to_string() } +#[cfg(not(feature = "video"))] +pub fn fetch_video( + _input: &str, + _target_width: u32, + _target_height: u32, +) -> Result { + Err(ValidationError::VideoNotSupported) +} + +#[cfg(feature = "video")] pub fn fetch_video( input: &str, target_width: u32, @@ -1091,6 +1106,8 @@ pub enum ValidationError { IoError(#[from] std::io::Error), #[error("ffmpeg error")] FFmpegError, + #[error("video not supported")] + VideoNotSupported, } #[cfg(test)]