diart
diart copied to clipboard
Create a Docker image
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
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
thanks @sorgfresser ! I think you could simplify that by using python:3.10-bookworm. Also, no need to use venv, right?
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?
Would be so great to have a docker image instead of using conda and to avoid having several version bugs between environment & requirement.
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"]