File size: 4,231 Bytes
5121390
3ed927c
5121390
 
 
 
 
 
 
3ed927c
730b419
286fadf
5121390
730b419
 
 
5121390
 
 
 
f6a5927
5121390
 
f6a5927
 
72697d5
f6a5927
 
5121390
730b419
5121390
 
 
 
 
 
 
730b419
 
5121390
 
730b419
0c47b59
5121390
730b419
 
4c3038e
 
5121390
 
 
 
 
 
730b419
 
 
5121390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72697d5
730b419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5121390
 
730b419
 
 
5121390
 
ab4cfa4
 
234b6b2
ab4cfa4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# ORI --> cuDNN error: CUDNN_STATUS_SUBLIBRARY_VERSION_MISMATCH
FROM nvidia/cuda:12.8.1-cudnn-runtime-ubuntu22.04
# TESTS UNTIL RIGHT PYTHON VERSION
# FROM nvidia/cuda:11.6.1-devel-ubuntu20.04
# FROM nvidia/cuda:12.0.0-cudnn8-devel-ubuntu18.04
# FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
# FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04
# FROM nvidia/cuda:12.1.0-cudnn8-runtime-ubuntu22.04
# FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04
# FROM nvcr.io/nvidia/pytorch:24.07-py3

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1

WORKDIR /app

ARG EXTRAS
ARG HF_PRECACHE_DIR
ARG HF_TKN_FILE

ENV HF_HOME="/app/tmp/cache/huggingface"
ENV HF_HUB_CACHE="/app/tmp/cache/huggingface/hub"
ENV XDG_CACHE_HOME="/app/tmp/cache/huggingface"
ENV LIBROSA_CACHE_DIR="/app/tmp/librosa_cache"
ENV NUMBA_CACHE_DIR="/app/tmp/numba_cache"
ENV MPLCONFIGDIR="/app/tmp/matplotlib"
ENV HF_HUB_ETAG_TIMEOUT="600"
ENV HF_HUB_DOWNLOAD_TIMEOUT="600"
ENV LD_LIBRARY_PATH="/usr/local/cuda:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}"

# Install system dependencies
#RUN apt-get update && \
#    apt-get install -y ffmpeg git && \
#    apt-get clean && \
#    rm -rf /var/lib/apt/lists/*

# 2) Install system dependencies + Python + pip
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        python3 \
        python3-pip \
        ffmpeg \
        git \
        libportaudio2 && \
    rm -rf /var/lib/apt/lists/*

RUN apt-get update && \
    apt-get install -y libaio1 libaio-dev

# RUN apt-get install -y --no-install-recommends libportaudio2
# portaudio19-dev

RUN pip install diart sounddevice
RUN pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

COPY . .

RUN mkdir -p $HF_HOME && \
    mkdir -p $HF_HUB_CACHE && \
    mkdir -p $XDG_CACHE_HOME && \
    mkdir -p $LIBROSA_CACHE_DIR && \
    mkdir -p $NUMBA_CACHE_DIR && \
    mkdir -p $MPLCONFIGDIR && \
    chmod 777 $HF_HOME && \
    chmod 777 $HF_HUB_CACHE && \
    chmod 777 $XDG_CACHE_HOME && \
    chmod 777 $LIBROSA_CACHE_DIR && \
    chmod 777 $NUMBA_CACHE_DIR && \
    chmod 777 $MPLCONFIGDIR && \
    chmod -R 777 /app

RUN mkdir -p /.cache && chmod -R 777 /.cache

# Install WhisperLiveKit directly, allowing for optional dependencies
#   Note: For gates modedls, need to add your HF toke. See README.md
#         for more details.
RUN if [ -n "$EXTRAS" ]; then \
      echo "Installing with extras: [$EXTRAS]"; \
      pip install --no-cache-dir .[$EXTRAS]; \
    else \
      echo "Installing base package only"; \
      pip install --no-cache-dir .; \
    fi

# Enable in-container caching for Hugging Face models by: 
# Note: If running multiple containers, better to map a shared
# bucket. 
#
# A) Make the cache directory persistent via an anonymous volume.
#    Note: This only persists for a single, named container. This is 
#          only for convenience at de/test stage. 
#          For prod, it is better to use a named volume via host mount/k8s.
VOLUME ["/root/.cache/huggingface/hub"]

# or
# B) Conditionally copy a local pre-cache from the build context to the 
#    container's cache via the HF_PRECACHE_DIR build-arg.
#    WARNING: This will copy ALL files in the pre-cache location.

# Conditionally copy a cache directory if provided
RUN if [ -n "$HF_PRECACHE_DIR" ]; then \
      echo "Copying Hugging Face cache from $HF_PRECACHE_DIR"; \
      mkdir -p /root/.cache/huggingface/hub && \
      cp -r $HF_PRECACHE_DIR/* /root/.cache/huggingface/hub; \
    else \
      echo "No local Hugging Face cache specified, skipping copy"; \
    fi

# Conditionally copy a Hugging Face token if provided

RUN if [ -n "$HF_TKN_FILE" ]; then \
      echo "Copying Hugging Face token from $HF_TKN_FILE"; \
      mkdir -p /root/.cache/huggingface && \
      cp $HF_TKN_FILE /root/.cache/huggingface/token; \
    else \
      echo "No Hugging Face token file specified, skipping token setup"; \
    fi
    
# Expose port for the transcription server
EXPOSE 8000

ENTRYPOINT ["whisperlivekit-server", "--host", "0.0.0.0"]

# Default args
# CMD ["--model", "tiny", "--diarization"]
CMD ["--model", "large-v2", \
     "--diarization", \
     "--language", "es", \
     "--buffer_trimming_sec", "2"]