abhiAI777 commited on
Commit
a1a55de
·
verified ·
1 Parent(s): e656dba

Upload run_pod.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. run_pod.sh +19 -19
run_pod.sh CHANGED
@@ -1,19 +1,19 @@
1
- #!/bin/bash
2
- # Pod entrypoint. Env: HF_TOKEN, KILL_AFTER (hard watchdog seconds), TRAIN_BUDGET (seconds for real training)
3
- cd /workspace
4
- kill_pod() { runpodctl remove pod $RUNPOD_POD_ID || curl -s -X DELETE -H "Authorization: Bearer $RUNPOD_API_KEY" https://rest.runpod.io/v1/pods/$RUNPOD_POD_ID; }
5
- ( sleep ${KILL_AFTER:-9000}; echo WATCHDOG; kill_pod ) &
6
- trap kill_pod EXIT
7
- pip install -q -U transformers peft datasets accelerate huggingface_hub sentencepiece 2>&1 | tail -2
8
- python -c "
9
- from huggingface_hub import hf_hub_download
10
- hf_hub_download('aixonlab/svg-slm-scripts','train.py',local_dir='/workspace',token='$HF_TOKEN')"
11
- PROBE=1 MAX_STEPS=10 python train.py 2>&1 | tee probe.log
12
- STEPS=$(python -c "
13
- import json;p=json.load(open('/workspace/probe.json'));b=float('${TRAIN_BUDGET:-7200}')
14
- print(int(min(p['full_steps'], b/p['sec_per_step']*0.95)))")
15
- echo STEPS=$STEPS
16
- MAX_STEPS=$STEPS TRAIN_SECONDS=${TRAIN_BUDGET:-7200} python train.py 2>&1 | tee train.log
17
- python -c "
18
- from huggingface_hub import HfApi
19
- HfApi(token='$HF_TOKEN').upload_file(path_or_fileobj='/workspace/train.log',path_in_repo='train.log',repo_id='aixonlab/svg-slm-4b-lora')"
 
1
+ #!/bin/bash
2
+ # Pod entrypoint. Env: HF_TOKEN, KILL_AFTER (hard watchdog seconds), TRAIN_BUDGET (seconds for real training)
3
+ cd /workspace
4
+ kill_pod() { python -c "import os,json,urllib.request as u;p=os.environ['RUNPOD_POD_ID'];q={'query':'mutation{podTerminate(input:{podId:\\\"'+p+'\\\"})}'};u.urlopen(u.Request('https://api.runpod.io/graphql',data=json.dumps(q).encode(),headers={'Authorization':'Bearer '+os.environ['RUNPOD_API_KEY'],'Content-Type':'application/json'}))"; }
5
+ ( sleep ${KILL_AFTER:-9000}; echo WATCHDOG; kill_pod ) &
6
+ trap kill_pod EXIT
7
+ pip install -q -U transformers peft datasets accelerate huggingface_hub sentencepiece 2>&1 | tail -2
8
+ python -c "
9
+ from huggingface_hub import hf_hub_download
10
+ hf_hub_download('aixonlab/svg-slm-scripts','train.py',local_dir='/workspace',token='$HF_TOKEN')"
11
+ PROBE=1 MAX_STEPS=10 python train.py 2>&1 | tee probe.log
12
+ STEPS=$(python -c "
13
+ import json;p=json.load(open('/workspace/probe.json'));b=float('${TRAIN_BUDGET:-7200}')
14
+ print(int(min(p['full_steps'], b/p['sec_per_step']*0.95)))")
15
+ echo STEPS=$STEPS
16
+ MAX_STEPS=$STEPS TRAIN_SECONDS=${TRAIN_BUDGET:-7200} python train.py 2>&1 | tee train.log
17
+ python -c "
18
+ from huggingface_hub import HfApi
19
+ HfApi(token='$HF_TOKEN').upload_file(path_or_fileobj='/workspace/train.log',path_in_repo='train.log',repo_id='aixonlab/svg-slm-4b-lora')"