Multi-stage Dockerfile for decord CUDA build
Use devel image for compilation, runtime for final image. Keeps image smaller while enabling NVDEC decode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,32 @@
|
|||||||
# GPU-enabled worker image
|
# GPU-enabled worker image
|
||||||
# Based on NVIDIA CUDA with Python for CuPy support
|
# Multi-stage build: use devel image for compiling, runtime for final image
|
||||||
|
|
||||||
|
# Stage 1: Build decord with CUDA
|
||||||
|
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 AS builder
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
python3.11 \
|
||||||
|
python3.11-venv \
|
||||||
|
python3.11-dev \
|
||||||
|
python3-pip \
|
||||||
|
git \
|
||||||
|
cmake \
|
||||||
|
build-essential \
|
||||||
|
pkg-config \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& ln -sf /usr/bin/python3.11 /usr/bin/python3 \
|
||||||
|
&& ln -sf /usr/bin/python3 /usr/bin/python
|
||||||
|
|
||||||
|
# Build decord with CUDA support
|
||||||
|
RUN git clone --recursive https://github.com/dmlc/decord /tmp/decord && \
|
||||||
|
cd /tmp/decord && \
|
||||||
|
mkdir build && cd build && \
|
||||||
|
cmake .. -DUSE_CUDA=ON -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_CUDA_ARCHITECTURES="70;75;80;86;89;90" && \
|
||||||
|
make -j$(nproc) && \
|
||||||
|
cd ../python && pip install --target=/decord-install .
|
||||||
|
|
||||||
|
# Stage 2: Runtime image
|
||||||
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -26,18 +52,10 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||||||
# Install GPU-specific dependencies (CuPy for CUDA 12.x)
|
# Install GPU-specific dependencies (CuPy for CUDA 12.x)
|
||||||
RUN pip install --no-cache-dir cupy-cuda12x
|
RUN pip install --no-cache-dir cupy-cuda12x
|
||||||
|
|
||||||
# Build decord from source with CUDA support for GPU-native video decoding
|
# Copy decord from builder stage
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
COPY --from=builder /decord-install /usr/local/lib/python3.11/dist-packages/
|
||||||
cmake build-essential \
|
COPY --from=builder /tmp/decord/build/libdecord.so /usr/local/lib/
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
RUN ldconfig
|
||||||
|
|
||||||
RUN git clone --recursive https://github.com/dmlc/decord /tmp/decord && \
|
|
||||||
cd /tmp/decord && \
|
|
||||||
mkdir build && cd build && \
|
|
||||||
cmake .. -DUSE_CUDA=ON -DCMAKE_BUILD_TYPE=Release && \
|
|
||||||
make -j$(nproc) && \
|
|
||||||
cd ../python && pip install . && \
|
|
||||||
rm -rf /tmp/decord
|
|
||||||
|
|
||||||
# Copy application
|
# Copy application
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
Reference in New Issue
Block a user