arindae commited on
Commit
cbf2f35
·
verified ·
1 Parent(s): a633207

Upload 24 files

Browse files
Files changed (2) hide show
  1. Dockerfile +16 -9
  2. entrypoint.sh +5 -0
Dockerfile CHANGED
@@ -1,26 +1,33 @@
1
  FROM python:3.11-slim
2
  WORKDIR /app
3
 
 
 
 
 
 
 
4
  COPY backend/requirements.txt backend/requirements-convert.txt ./
5
  RUN pip install --no-cache-dir -r requirements.txt \
6
  && pip install --no-cache-dir -r requirements-convert.txt --extra-index-url https://download.pytorch.org/whl/cpu
7
 
8
  # FIX 1: Catch ALL .so files inside the ctranslate2 package (including Python bindings)
9
- RUN apt-get update && apt-get install -y --no-install-recommends patchelf \
10
- && SO_FILES=$(find /usr/local/lib/python3.11/site-packages -name '*.so*' -path '*ctranslate2*' 2>/dev/null) \
11
  && echo "Found CTranslate2 .so files: $SO_FILES" \
12
- && for f in $SO_FILES; do patchelf --clear-execstack "$f" && echo "Patched: $f"; done \
13
- && apt-get purge -y patchelf && apt-get autoremove -y \
14
- && rm -rf /var/lib/apt/lists/*
15
 
16
  COPY . .
17
  COPY entrypoint.sh .
18
  RUN chmod +x entrypoint.sh
19
 
20
- # FIX 2: Create a user with UID 1000 and grant ownership of the working dir
21
- # so that entrypoint.sh has permission to save the models during runtime conversion.
22
- RUN useradd -m -u 1000 user \
23
- && chown -R user:user /app
 
 
 
 
24
 
25
  USER user
26
 
 
1
  FROM python:3.11-slim
2
  WORKDIR /app
3
 
4
+ # Install system dependencies (libgomp1 is needed for CTranslate2 multi-threading)
5
+ RUN apt-get update && apt-get install -y --no-install-recommends \
6
+ libgomp1 \
7
+ patchelf \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
  COPY backend/requirements.txt backend/requirements-convert.txt ./
11
  RUN pip install --no-cache-dir -r requirements.txt \
12
  && pip install --no-cache-dir -r requirements-convert.txt --extra-index-url https://download.pytorch.org/whl/cpu
13
 
14
  # FIX 1: Catch ALL .so files inside the ctranslate2 package (including Python bindings)
15
+ RUN SO_FILES=$(find /usr/local/lib/python3.11/site-packages -name '*.so*' -path '*ctranslate2*' 2>/dev/null) \
 
16
  && echo "Found CTranslate2 .so files: $SO_FILES" \
17
+ && for f in $SO_FILES; do patchelf --clear-execstack "$f" && echo "Patched: $f"; done
 
 
18
 
19
  COPY . .
20
  COPY entrypoint.sh .
21
  RUN chmod +x entrypoint.sh
22
 
23
+ # CRITICAL FIX 2: Create /data/models and grant permissions to UID 1000
24
+ # so entrypoint.sh can write models to /data/models/ without PermissionError
25
+ RUN mkdir -p /data/models \
26
+ && useradd -m -u 1000 user \
27
+ && chown -R user:user /app /data
28
+
29
+ # Set OpenMP thread configuration for optimal performance on 8 vCPUs
30
+ ENV OMP_NUM_THREADS=8
31
 
32
  USER user
33
 
entrypoint.sh CHANGED
@@ -15,5 +15,10 @@ HF_MODEL="google/madlad400-3b-mt" \
15
  CT2_MODEL_DIR="/data/models/madlad400-3b-mt-int8" \
16
  python backend/convert_model.py || echo "WARNING: MADLAD conversion failed, continuing"
17
 
 
 
 
 
 
18
  echo "== Starting server =="
19
  cd backend && exec uvicorn main:app --host 0.0.0.0 --port 7860
 
15
  CT2_MODEL_DIR="/data/models/madlad400-3b-mt-int8" \
16
  python backend/convert_model.py || echo "WARNING: MADLAD conversion failed, continuing"
17
 
18
+ echo "== Converting Sunbird NLLB 3.3B =="
19
+ HF_MODEL="Sunbird/translate-nllb-3.3b-salt" \
20
+ CT2_MODEL_DIR="/data/models/sunbird-nllb-3.3b-int8" \
21
+ python backend/convert_model.py || echo "WARNING: Sunbird NLLB 3.3B conversion failed, continuing"
22
+
23
  echo "== Starting server =="
24
  cd backend && exec uvicorn main:app --host 0.0.0.0 --port 7860