Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Docker image #195

Open
juanmc2005 opened this issue Nov 1, 2023 · 5 comments
Open

Create a Docker image #195

juanmc2005 opened this issue Nov 1, 2023 · 5 comments
Labels
ops Improvements to the project that don't impact the code

Comments

@juanmc2005
Copy link
Owner

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 juanmc2005 added the ops Improvements to the project that don't impact the code label Nov 1, 2023
@juanmc2005 juanmc2005 modified the milestone: Version 0.9 Nov 1, 2023
@sorgfresser
Copy link
Contributor

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

@juanmc2005
Copy link
Owner Author

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

@v-nhandt21
Copy link

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?

@4u9ur
Copy link

4u9ur commented Apr 29, 2024

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

@kartheekmedathati
Copy link

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"]                                                                                                                                                                                                                                                                                                               

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ops Improvements to the project that don't impact the code
Projects
None yet
Development

No branches or pull requests

5 participants