sachin
commited on
Commit
·
7fbf9f0
1
Parent(s):
a9b565f
test
Browse files- Dockerfile +40 -9
Dockerfile
CHANGED
@@ -1,39 +1,70 @@
|
|
1 |
FROM nvidia/cuda:12.8.0-cudnn-devel-ubuntu22.04
|
2 |
WORKDIR /app
|
3 |
|
|
|
4 |
RUN apt-get update && apt-get install -y \
|
5 |
python3 \
|
6 |
-
python3-pip python3-distutils python3-dev python3-venv\
|
7 |
git \
|
8 |
ffmpeg \
|
9 |
-
sudo wget curl software-properties-common build-essential gcc g++ \
|
10 |
&& ln -s /usr/bin/python3 /usr/bin/python \
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
|
|
13 |
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
14 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
15 |
|
16 |
-
|
17 |
-
|
|
|
18 |
|
|
|
19 |
RUN pip install --upgrade pip setuptools setuptools-rust torch
|
20 |
RUN pip install flash-attn --no-build-isolation
|
21 |
|
|
|
22 |
COPY requirements.txt .
|
23 |
COPY dhwani_config.json .
|
24 |
-
|
25 |
-
#
|
26 |
RUN pip install --no-cache-dir -r requirements.txt
|
27 |
-
#RUN pip install git+https://github.com/ai4bharat/IndicF5.git
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
COPY . .
|
30 |
|
|
|
31 |
RUN useradd -ms /bin/bash appuser \
|
32 |
&& chown -R appuser:appuser /app
|
33 |
-
|
34 |
USER appuser
|
35 |
|
|
|
36 |
EXPOSE 7860
|
37 |
|
38 |
-
#
|
39 |
CMD ["python", "/app/src/server/main.py", "--host", "0.0.0.0", "--port", "7860", "--config", "config_two"]
|
|
|
1 |
FROM nvidia/cuda:12.8.0-cudnn-devel-ubuntu22.04
|
2 |
WORKDIR /app
|
3 |
|
4 |
+
# Install system dependencies
|
5 |
RUN apt-get update && apt-get install -y \
|
6 |
python3 \
|
7 |
+
python3-pip python3-distutils python3-dev python3-venv \
|
8 |
git \
|
9 |
ffmpeg \
|
10 |
+
sudo wget curl software-properties-common build-essential gcc g++ \
|
11 |
&& ln -s /usr/bin/python3 /usr/bin/python \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
+
# Install Rust
|
15 |
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
16 |
ENV PATH="/root/.cargo/bin:${PATH}"
|
17 |
|
18 |
+
# Set compiler environment variables
|
19 |
+
ENV CC=/usr/bin/gcc
|
20 |
+
ENV CXX=/usr/bin/g++
|
21 |
|
22 |
+
# Upgrade pip and install base Python dependencies
|
23 |
RUN pip install --upgrade pip setuptools setuptools-rust torch
|
24 |
RUN pip install flash-attn --no-build-isolation
|
25 |
|
26 |
+
# Copy requirements and configuration files
|
27 |
COPY requirements.txt .
|
28 |
COPY dhwani_config.json .
|
29 |
+
|
30 |
+
# Install Python dependencies
|
31 |
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
32 |
|
33 |
+
# Create a directory for pre-downloaded models
|
34 |
+
RUN mkdir -p /app/models
|
35 |
+
|
36 |
+
# Pre-download models using a Python script during build
|
37 |
+
RUN python -c "\
|
38 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, AutoProcessor, AutoModel; \
|
39 |
+
from transformers import Gemma3ForConditionalGeneration; \
|
40 |
+
import os; \
|
41 |
+
models = { \
|
42 |
+
'llm_model': ('google/gemma-3-4b-it', Gemma3ForConditionalGeneration, AutoProcessor), \
|
43 |
+
'tts_model': ('ai4bharat/IndicF5', AutoModel, None), \
|
44 |
+
'asr_model': ('ai4bharat/indic-conformer-600m-multilingual', AutoModel, None), \
|
45 |
+
'trans_en_indic': ('ai4bharat/indictrans2-en-indic-dist-200M', AutoModelForSeq2SeqLM, AutoTokenizer), \
|
46 |
+
'trans_indic_en': ('ai4bharat/indictrans2-indic-en-dist-200M', AutoModelForSeq2SeqLM, AutoTokenizer), \
|
47 |
+
'trans_indic_indic': ('ai4bharat/indictrans2-indic-indic-dist-320M', AutoModelForSeq2SeqLM, AutoTokenizer), \
|
48 |
+
}; \
|
49 |
+
for name, (model_name, model_class, processor_class) in models.items(): \
|
50 |
+
print(f'Downloading {model_name}...'); \
|
51 |
+
model = model_class.from_pretrained(model_name, trust_remote_code=True); \
|
52 |
+
model.save_pretrained(f'/app/models/{name}'); \
|
53 |
+
if processor_class: \
|
54 |
+
processor = processor_class.from_pretrained(model_name, trust_remote_code=True); \
|
55 |
+
processor.save_pretrained(f'/app/models/{name}'); \
|
56 |
+
"
|
57 |
+
|
58 |
+
# Copy application code
|
59 |
COPY . .
|
60 |
|
61 |
+
# Set up user
|
62 |
RUN useradd -ms /bin/bash appuser \
|
63 |
&& chown -R appuser:appuser /app
|
|
|
64 |
USER appuser
|
65 |
|
66 |
+
# Expose port
|
67 |
EXPOSE 7860
|
68 |
|
69 |
+
# Start the server
|
70 |
CMD ["python", "/app/src/server/main.py", "--host", "0.0.0.0", "--port", "7860", "--config", "config_two"]
|