fix: feature flag video and remove from non cuda dockerfiles

This commit is contained in:
drbh 2024-12-13 17:36:34 +00:00
parent 5322abd9f5
commit b4da6ad30e
6 changed files with 24 additions and 46 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -77,3 +77,4 @@ default = ["ngrok"]
ngrok = ["dep:ngrok"]
google = []
kserve = []
video = []

View File

@ -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<ProcessedVideo, ValidationError> {
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)]