Raphael Glon commited on
Commit
326d1f8
·
unverified ·
1 Parent(s): 5cfe118

Change spaces sdk: use custom dockerfile rather than the spaces one

Browse files
Files changed (2) hide show
  1. Dockerfile +91 -0
  2. README.md +2 -4
Dockerfile ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:22.04 AS root
2
+ ENV DEBIAN_FRONTEND=noninteractive \
3
+ TZ=Europe/Paris
4
+ RUN apt-get update && apt-get install -y fakeroot wget gnupg && \
5
+ mv /usr/bin/apt-get /usr/bin/.apt-get && \
6
+ echo '#!/usr/bin/env sh\nfakeroot /usr/bin/.apt-get $@' > /usr/bin/apt-get && \
7
+ chmod +x /usr/bin/apt-get && \
8
+ rm -rf /var/lib/apt/lists/* && \
9
+ useradd -m -u 1000 user
10
+
11
+ FROM scratch AS base
12
+ COPY --chown=1000:1000 --from=root / /
13
+ USER user
14
+ ENV HOME=/home/user \
15
+ PATH=/home/user/.local/bin:$PATH \
16
+ DEBIAN_FRONTEND=noninteractive \
17
+ TZ=Europe/Paris
18
+ WORKDIR /home/user/app
19
+ # Neuron setup
20
+ ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/opt/aws/neuron/lib
21
+ # AWS Neuron GPG Key
22
+ RUN wget -qO /tmp/neuron.asc https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB && \
23
+ gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --import /tmp/neuron.asc && \
24
+ gpg --no-default-keyring --keyring /tmp/temp-keyring.gpg --export --output /etc/apt/trusted.gpg.d/neuron.gpg && \
25
+ echo "deb https://apt.repos.neuron.amazonaws.com jammy main" > /etc/apt/sources.list.d/neuron.list
26
+
27
+ RUN apt-get update && apt-get install -y \
28
+ git \
29
+ git-lfs \
30
+ ffmpeg \
31
+ libsm6 \
32
+ libxext6 \
33
+ cmake \
34
+ rsync \
35
+ libgl1 \
36
+ aws-neuronx-tools \
37
+ aws-neuronx-collectives \
38
+ aws-neuronx-runtime-lib \
39
+ pip \
40
+ socat \
41
+ && rm -rf /var/lib/apt/lists/* \
42
+ && git lfs install
43
+
44
+ ENV PATH =/opt/aws/neuron/bin:$PATH
45
+
46
+ ARG OPTIMUM_NEURON_VERSION=0.3.0
47
+ RUN pip install --extra-index-url https://pip.repos.neuron.amazonaws.com --no-cache-dir optimum-neuron[neuronx]==$OPTIMUM_NEURON_VERSION
48
+ # End Neuron setup
49
+ RUN pip install --no-cache-dir pip -U && \
50
+ pip install --no-cache-dir \
51
+ datasets \
52
+ "huggingface-hub>=0.19" "hf_xet>=1.0.0,<2.0.0" "hf-transfer>=0.1.4" "protobuf<4" "click<8.1" "pydantic~=1.0"
53
+ RUN \
54
+ apt-get update && \
55
+ apt-get install -y curl && \
56
+ curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
57
+ apt-get install -y nodejs && \
58
+ rm -rf /var/lib/apt/lists/* && apt-get clean
59
+ # Python packages
60
+ RUN --mount=target=/tmp/requirements.txt,source=requirements.txt \
61
+ pip install --no-cache-dir -r /tmp/requirements.txt
62
+
63
+ # Streamlit and Gradio
64
+ RUN pip install --no-cache-dir \
65
+ gradio[oauth,mcp]==5.31.0 \
66
+ "uvicorn>=0.14.0" \
67
+ spaces
68
+
69
+ ENTRYPOINT ["python3", "./app.py"]
70
+
71
+ FROM base AS pipfreeze
72
+ RUN pip freeze > /tmp/freeze.txt
73
+ FROM base AS run
74
+ COPY --link --chown=1000 ./ /home/user/app
75
+ # Warning, if you change something under this line, dont forget to change the PIP_FREEZE_REVERSED_INDEX
76
+ COPY --from=pipfreeze --link --chown=1000 /tmp/freeze.txt /tmp/freeze.txt
77
+ ENV PYTHONPATH=$HOME/app \
78
+ PYTHONUNBUFFERED=1 \
79
+ HF_HUB_ENABLE_HF_TRANSFER=1 \
80
+ GRADIO_ALLOW_FLAGGING=never \
81
+ GRADIO_FLAGGING_MODE=never \
82
+ GRADIO_CACHE_EXAMPLES=true \
83
+ GRADIO_NUM_PORTS=1 \
84
+ GRADIO_SERVER_NAME=0.0.0.0 \
85
+ GRADIO_SSR_MODE=True \
86
+ GRADIO_THEME=huggingface \
87
+ TQDM_POSITION=-1 \
88
+ TQDM_MININTERVAL=1 \
89
+ SYSTEM=spaces
90
+
91
+
README.md CHANGED
@@ -3,9 +3,7 @@ title: Export to AWS Neuron
3
  emoji: 🏎️
4
  colorFrom: yellow
5
  colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.31.0
8
- app_file: app.py
9
  hf_oauth: true
10
  hf_oauth_scopes:
11
  - read-repos
@@ -15,4 +13,4 @@ license: apache-2.0
15
  short_description: 'Export HF models to AWS Neuron-optimized format for Trn/Inf '
16
  ---
17
 
18
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
3
  emoji: 🏎️
4
  colorFrom: yellow
5
  colorTo: purple
6
+ sdk: docker
 
 
7
  hf_oauth: true
8
  hf_oauth_scopes:
9
  - read-repos
 
13
  short_description: 'Export HF models to AWS Neuron-optimized format for Trn/Inf '
14
  ---
15
 
16
+ An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).