mnemo-ocr-core / Dockerfile.gpu
MABobrov's picture
Fix Docker heredoc for NVIDIA libs
4a4193f
FROM node:20-bookworm-slim AS web-builder
WORKDIR /src/web-new
COPY web-new/package*.json ./
RUN npm ci
COPY web-new/ ./
RUN npm run build
FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=7860 \
OMP_NUM_THREADS=1 \
MKL_NUM_THREADS=1 \
MNEMO_NVIDIA_LIB_DIR=/usr/local/lib/mnemo-nvidia \
LD_LIBRARY_PATH=/usr/local/lib/mnemo-nvidia:/usr/local/lib \
WEB_ROOT=/app/web \
FRONTEND_MODE=studio \
MNEMO_DETECTOR_MODE=hf-demo \
MNEMO_ANALYZE_USE_EXCEL=1 \
MNEMO_PADDLE_DEVICE=gpu \
MNEMO_EASYOCR_DEVICE=cuda \
MNEMO_SENSOR_OCR_ENGINE=paddle
ARG PADDLE_PACKAGE=paddlepaddle-gpu==2.6.2
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ build-essential \
libglib2.0-0 libgl1 libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.gpu.txt .
RUN pip install --upgrade pip setuptools wheel \
&& pip install "${PADDLE_PACKAGE}" \
&& pip install -r requirements.gpu.txt
RUN python - <<'PY'
from pathlib import Path
import site
root = Path('/usr/local/lib/mnemo-nvidia')
root.mkdir(parents=True, exist_ok=True)
for base in site.getsitepackages():
nvidia = Path(base) / 'nvidia'
if not nvidia.exists():
continue
for lib_dir in nvidia.glob('*/lib'):
for lib_path in lib_dir.glob('*.so*'):
link_path = root / lib_path.name
if link_path.exists() or link_path.is_symlink():
continue
link_path.symlink_to(lib_path)
PY
RUN ldconfig
COPY . .
COPY --from=web-builder /src/web /app/web
EXPOSE 7860
CMD ["python", "app.py", "--frontend-mode", "studio"]