Z User commited on
Commit
40b597c
·
1 Parent(s): c2cb3d9

LAL training worker 2

Browse files
Files changed (3) hide show
  1. README.md +6 -8
  2. app.py +46 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,13 +1,11 @@
1
  ---
2
- title: Lal Train 2
3
- emoji: 🏢
4
- colorFrom: gray
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 6.24.0
8
- python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
  ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: LAL Train 2
3
+ emoji: 🧠
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: "4.0.0"
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
+ LAL distributed training worker 2.
 
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, threading
2
+ import gradio as gr
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ WORK_DIR = "/data/lalmodel"
6
+ os.makedirs(WORK_DIR, exist_ok=True)
7
+
8
+ def log(msg):
9
+ print(f"[SPACE] {msg}", flush=True)
10
+
11
+ def setup():
12
+ log("Setting up...")
13
+ if not os.path.exists(f"{WORK_DIR}/.git"):
14
+ os.system(f"git clone https://github.com/samaidev/lalmodel.git {WORK_DIR}")
15
+ if not os.path.exists(f"{WORK_DIR}/data/large_bpe_v3.bin"):
16
+ try:
17
+ p = hf_hub_download(repo_id="gasschina/lalmodel-code", filename="data/large_bpe_v3.bin", repo_type="model")
18
+ os.system(f"mkdir -p {WORK_DIR}/data && cp {p} {WORK_DIR}/data/")
19
+ except: pass
20
+ try:
21
+ p = hf_hub_download(repo_id="tchbcb/lalmodel-distributed", filename="merged_ckpt.ste", repo_type="model")
22
+ os.system(f"cp {p} {WORK_DIR}/model_dialogue.ste")
23
+ except: pass
24
+ if not os.path.exists(f"{WORK_DIR}/ste_train"):
25
+ os.system(f"cd {WORK_DIR} && make 2>&1 | tail -3")
26
+ os.system(f"cd {WORK_DIR} && OMP_NUM_THREADS=2 OMP_MAX_ACTIVE_LEVELS=1 nohup ./ste_train > train.log 2> train.err &")
27
+ log("Training started")
28
+
29
+ threading.Thread(target=setup, daemon=True).start()
30
+
31
+ def get_progress():
32
+ try:
33
+ with open(f"{WORK_DIR}/train.log") as f:
34
+ lines = f.readlines()[-10:]
35
+ return "```\n" + "".join(lines) + "\n```"
36
+ except:
37
+ return "Starting..."
38
+
39
+ with gr.Blocks() as demo:
40
+ gr.Markdown("# LAL Training Worker 2")
41
+ out = gr.Markdown(value="Starting...")
42
+ btn = gr.Button("Refresh")
43
+ btn.click(get_progress, outputs=out)
44
+ demo.load(get_progress, outputs=out)
45
+
46
+ demo.launch(server_name="0.0.0.0", server_port=7860)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==4.0.0
2
+ huggingface_hub