Jayant-Kernel commited on
Commit
3470129
·
unverified ·
1 Parent(s): 237e430

fix: install deps in Dockerfile build, not runtime

Browse files
Files changed (2) hide show
  1. Dockerfile +27 -4
  2. train.py +1 -11
Dockerfile CHANGED
@@ -1,8 +1,31 @@
1
- FROM python:3.10-slim
2
- RUN apt-get update && apt-get install -y git build-essential && rm -rf /var/lib/apt/lists/*
3
- WORKDIR /app
4
- COPY train.py .
5
  ENV PYTHONUNBUFFERED=1
6
  ENV HF_HOME=/tmp/huggingface
7
  ENV MPLCONFIGDIR=/tmp/matplotlib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  CMD ["python", "train.py"]
 
1
+ FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu22.04
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive
 
4
  ENV PYTHONUNBUFFERED=1
5
  ENV HF_HOME=/tmp/huggingface
6
  ENV MPLCONFIGDIR=/tmp/matplotlib
7
+ ENV PIP_CACHE_DIR=/tmp/pip-cache
8
+
9
+ RUN apt-get update && apt-get install -y \
10
+ python3.10 python3-pip git build-essential \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ RUN ln -s /usr/bin/python3.10 /usr/bin/python
14
+
15
+ WORKDIR /app
16
+
17
+ # Install all dependencies during build
18
+ RUN pip install --no-cache-dir \
19
+ "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git" \
20
+ --no-deps
21
+
22
+ RUN pip install --no-cache-dir \
23
+ trl peft accelerate bitsandbytes wandb datasets \
24
+ huggingface_hub torch transformers
25
+
26
+ RUN pip install --no-cache-dir \
27
+ git+https://github.com/Jayant-kernel/DECEIT-the-ai-truth-environment-.git
28
+
29
+ COPY train.py .
30
+
31
  CMD ["python", "train.py"]
train.py CHANGED
@@ -1,8 +1,6 @@
1
- import os, sys, pathlib, subprocess
2
  import threading
3
 
4
- os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
5
- os.environ["HF_HOME"] = "/tmp/huggingface"
6
  os.makedirs("/tmp/matplotlib", exist_ok=True)
7
  os.makedirs("/tmp/huggingface", exist_ok=True)
8
  from http.server import HTTPServer, BaseHTTPRequestHandler
@@ -24,14 +22,6 @@ health_thread = threading.Thread(target=start_health_server, daemon=True)
24
  health_thread.start()
25
  print("Health server started on port 7860")
26
 
27
- # Install deps
28
- subprocess.run([sys.executable, "-m", "pip", "install", "-q",
29
- "unsloth", "unsloth_zoo", "nest-asyncio"], check=True)
30
- subprocess.run([sys.executable, "-m", "pip", "install", "-q",
31
- "trl", "peft", "accelerate", "bitsandbytes", "wandb", "datasets",
32
- "git+https://github.com/Jayant-kernel/DECEIT-the-ai-truth-environment-.git"],
33
- check=True)
34
-
35
  import torch, json, re, threading, pathlib
36
  from unsloth import FastLanguageModel
37
  from trl import GRPOConfig, GRPOTrainer
 
1
+ import os, sys, pathlib
2
  import threading
3
 
 
 
4
  os.makedirs("/tmp/matplotlib", exist_ok=True)
5
  os.makedirs("/tmp/huggingface", exist_ok=True)
6
  from http.server import HTTPServer, BaseHTTPRequestHandler
 
22
  health_thread.start()
23
  print("Health server started on port 7860")
24
 
 
 
 
 
 
 
 
 
25
  import torch, json, re, threading, pathlib
26
  from unsloth import FastLanguageModel
27
  from trl import GRPOConfig, GRPOTrainer