File size: 2,087 Bytes
8a014fc
30c8277
9486367
 
8a014fc
 
 
 
 
 
 
 
 
 
 
 
 
 
9486367
 
 
 
8a014fc
 
 
 
8e769b9
 
5414d49
8a014fc
ba5cf51
30c8277
 
 
 
 
 
2065799
30c8277
 
 
 
 
 
 
347e8d7
8e769b9
571b077
8e769b9
 
 
 
571b077
 
8a014fc
571b077
 
 
23c7af2
6a3d23c
a37cf9d
571b077
8e769b9
 
 
 
 
 
571b077
 
 
8c2a228
ee63def
571b077
 
 
 
87146c8
97bc506
 
 
f113306
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
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04 AS llama_builder

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install --no-install-recommends -y \
  build-essential \
  python3-pip \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN python -m venv /opt/venv
ENV PATH=/opt/venv/bin:$PATH \
    NVIDIA_VISIBLE_DEVICES=all \
    NVIDIA_DRIVER_CAPABILITIES=compute,utility

RUN CMAKE_ARGS="-DLLAMA_CUDA=on" pip3 install --no-cache-dir llama-cpp-python

FROM nvcr.io/nvidia/pytorch:23.10-py3 AS dep_builder

RUN apt-get update && apt-get install --no-install-recommends -y \
  python3-pip \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN python -m venv /opt/venv
ENV PATH=/opt/venv/bin:$PATH \
    NVIDIA_VISIBLE_DEVICES=all \
    NVIDIA_DRIVER_CAPABILITIES=compute,utility
    
RUN pip3 install --no-cache-dir fastembed-gpu

FROM bitnami/minideb:bookworm

RUN apt-get update && apt-get install --no-install-recommends -y \
  curl \
  build-essential \
  ffmpeg \
  libsm6 \
  libxext6 \
  python3.10 \
  python3-pip \
  python3-dev \
  ninja-build \
  tesseract-ocr \
  poppler-utils \
  git \
  && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN python -m venv /opt/venv

COPY --from=llama_builder /opt/venv /opt/venv
COPY --from=dep_builder /opt/venv /opt/venv

WORKDIR /app

ENV HOME=/home/user \
	PATH=/opt/venv/bin:$PATH \
    PYTHONPATH=$HOME/app \
	PYTHONUNBUFFERED=1 \
    NVIDIA_VISIBLE_DEVICES=all \
    NVIDIA_DRIVER_CAPABILITIES=compute,utility \
	SYSTEM=spaces \
    HF_HOME=/data/.huggingface 

COPY ./requirements.txt /app/requirements.txt
RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt

RUN useradd -m -u 1000 user
USER user

WORKDIR $HOME/app

COPY --chown=user . $HOME/app

EXPOSE 8501
CMD streamlit run app.py \
    --server.headless true \
    --server.enableCORS false \
    --server.enableXsrfProtection false \
    --server.fileWatcherType watchdog \
    --theme.backgroundColor "#EEE3D3" \
    --theme.secondaryBackgroundColor "#CCC8C2" \
    --theme.primaryColor "#EF792D" \
    --theme.textColor "#7D6654"