diart icon indicating copy to clipboard operation
diart copied to clipboard

Create a Docker image

Open juanmc2005 opened this issue 2 years ago • 5 comments

Problem

Setting up the project is a bit too long with all the dependencies and the use of conda.

Idea

Create and publish docker images with new diart versions, allowing quick setup and deployment

juanmc2005 avatar Nov 01 '23 15:11 juanmc2005

I just wrote a really small dockerfile for internal usage but it might be feasible here too

ARG _BASE=debian:bookworm
FROM $_BASE as builder

COPY src /code/src
COPY setup.cfg setup.py requirements.txt pyproject.toml /code/

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip \
    python3-setuptools \
    python3-wheel \
    python3-dev \
    python3-venv \
    build-essential

RUN python3 -m venv /opt/venv
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"

RUN pip3 install /code

FROM $_BASE

# Runtime deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-venv \
    libportaudio2 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Get venv from builder
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder /opt/venv /opt/venv

sorgfresser avatar Nov 12 '23 22:11 sorgfresser

thanks @sorgfresser ! I think you could simplify that by using python:3.10-bookworm. Also, no need to use venv, right?

juanmc2005 avatar Nov 13 '23 13:11 juanmc2005

I just wrote a really small dockerfile for internal usage but it might be feasible here too

ARG _BASE=debian:bookworm
FROM $_BASE as builder

COPY src /code/src
COPY setup.cfg setup.py requirements.txt pyproject.toml /code/

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip \
    python3-setuptools \
    python3-wheel \
    python3-dev \
    python3-venv \
    build-essential

RUN python3 -m venv /opt/venv
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"

RUN pip3 install /code

FROM $_BASE

# Runtime deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-venv \
    libportaudio2 \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Get venv from builder
ARG PATH="/opt/venv/bin:$PATH"
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=builder /opt/venv /opt/venv

I got some problem with ffmpeg<4.4, how to correctly install it in docker?

v-nhandt21 avatar Jan 23 '24 08:01 v-nhandt21

Would be so great to have a docker image instead of using conda and to avoid having several version bugs between environment & requirement.

4u9ur avatar Apr 29 '24 00:04 4u9ur

Here is a docker that worked for me:

FROM docker.io/nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
RUN apt-get update && apt-get install -y software-properties-common wget

RUN wget https://bootstrap.pypa.io/get-pip.py && \
    python3 get-pip.py && \
    rm get-pip.py

RUN apt-get update && apt-get install -y \
    ffmpeg \
    libsndfile1 \
    && rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install torch torchvision torchaudio
RUN pip install --upgrade pip && \
    pip install \
    "numpy<2.0" \
    ffmpeg-python==0.2.0 \
    future==1.0.0 \
    librosa==0.10.2.post1 \
    soundfile==0.12.1 \
    transformers==4.45.0 \
    accelerate==0.34.2 \
    pyannote.audio==3.3.2 \
    diart==0.9.1 \                                                                                                                                                                                                                                                                                                         
    fastapi \                                                                                                                                                                                                                                                                                                              
    uvicorn \                                                                                                                                                                                                                                                                                                              
    python-multipart \                                                                                                                                                                                                                                                                                                     
    faster_whisper                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                           
RUN apt-get update && apt-get install -y portaudio19-dev python3-dev                                                                                                                                                                                                                                                       
RUN python3 -m pip install pyaudio                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                           
WORKDIR /Work                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                           
CMD ["bash"]                                                                                                                                                                                                                                                                                                               

kartheekmedathati avatar Dec 10 '24 21:12 kartheekmedathati