chane35 commited on
Commit
e037130
·
verified ·
1 Parent(s): 796da7c

Promote training Dockerfile to Space root

Browse files
Files changed (1) hide show
  1. Dockerfile +65 -0
Dockerfile ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.2.2-devel-ubuntu22.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+ ENV PYTHONUNBUFFERED=1
5
+ ENV PYTHONPATH=/home/user/app
6
+ ENV HF_HOME=/tmp/.cache/huggingface
7
+ ENV PIP_NO_CACHE_DIR=1
8
+
9
+ RUN apt-get update -y && \
10
+ apt-get install -y python3 python3-pip python3-venv git curl && \
11
+ python3 -m pip install --upgrade pip && \
12
+ apt-get clean && rm -rf /var/lib/apt/lists/*
13
+
14
+ RUN useradd -m -u 1000 user
15
+ USER user
16
+ ENV HOME=/home/user
17
+ ENV PATH=/home/user/.local/bin:$PATH
18
+ WORKDIR /home/user/app
19
+
20
+ # Install torch first (heaviest, cached separately)
21
+ RUN pip install torch==2.5.1+cu121 --index-url https://download.pytorch.org/whl/cu121
22
+
23
+ # Install unsloth's official Colab-compatible dependency bundle.
24
+ # This is the ONLY combination unsloth officially supports and tests.
25
+ RUN pip install "unsloth[colab-new]"
26
+
27
+ # Install unsloth core (no-deps to not override colab-new pins)
28
+ RUN pip install --no-deps "unsloth @ git+https://github.com/unslothai/unsloth.git"
29
+
30
+ # Install our additional deps (server + OpenEnv + matplotlib)
31
+ RUN pip install \
32
+ flask \
33
+ flask-cors \
34
+ fastapi \
35
+ uvicorn \
36
+ pydantic \
37
+ requests \
38
+ openenv-core \
39
+ PyYAML \
40
+ matplotlib
41
+
42
+ # Verify non-GPU imports work
43
+ RUN python3 -c "import torch; print(f'torch={torch.__version__}')" && \
44
+ python3 -c "import transformers; print(f'transformers={transformers.__version__}')" && \
45
+ python3 -c "import trl; print(f'trl={trl.__version__}')" && \
46
+ python3 -c "import datasets; print(f'datasets={datasets.__version__}')"
47
+
48
+ COPY --chown=user . /home/user/app
49
+
50
+ RUN pip install --no-deps -e /home/user/app
51
+
52
+ RUN python3 -m training.generate_warmup_traces
53
+
54
+ EXPOSE 7860
55
+
56
+ # The HF Space receives entrypoint.sh at repo root (promoted by tools/upload_all.py),
57
+ # but if someone builds locally from `deploy/training/` it's one directory up.
58
+ RUN if [ -f /home/user/app/entrypoint.sh ]; then \
59
+ chmod +x /home/user/app/entrypoint.sh; \
60
+ elif [ -f /home/user/app/deploy/training/entrypoint.sh ]; then \
61
+ cp /home/user/app/deploy/training/entrypoint.sh /home/user/app/entrypoint.sh && \
62
+ chmod +x /home/user/app/entrypoint.sh; \
63
+ fi
64
+
65
+ CMD ["/home/user/app/entrypoint.sh"]