File size: 1,666 Bytes
f66f92b
 
 
 
 
 
 
 
0e6f6f5
f66f92b
0e6f6f5
f66f92b
 
6731a16
 
 
 
6996067
f66f92b
6996067
 
f66f92b
6996067
f66f92b
 
7ddd724
f66f92b
 
 
 
0e6f6f5
f66f92b
 
 
 
 
6996067
7ddd724
4a4193f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f66f92b
 
6996067
f66f92b
 
 
 
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
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"]