-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart_server.py
59 lines (50 loc) · 1.88 KB
/
start_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from argparse import ArgumentParser
import os
import json
"""Usage: Host Model
python start_server.py --model codellama2-13b -t run --device 0
"""
"""Usage: Clear Model
python start_server.py --model codellama2-13b -t clear --device 0
"""
parser = ArgumentParser()
parser.add_argument("--model", type=str, default="codellama2-13b")
parser.add_argument("-t", type=str, default="clear", choices="run clear".split())
parser.add_argument("--device", type=str, default="0")
args = parser.parse_args()
ROOT = "" # local model root path
model = args.model
if model == "vicuna-7b":
model_path = "vicuna-7b-v1.5"
model_path = os.path.join(ROOT, model_path)
elif model == "vicuna-13b":
model_path = "vicuna-13b-v1.5"
model_path = os.path.join(ROOT, model_path)
elif model == "llama2-13b":
model_path = "llama-2-13b"
model_path = os.path.join(ROOT, model_path)
elif model == "llama2-7b":
model_path = "NousResearch/Llama-2-7b-chat-hf"
elif model == "codellama2-13b":
model_path = "codellama/CodeLlama-13b-Instruct-hf"
# model_path = os.path.join(ROOT, model_path)
elif model == "chatglm2-6b":
model_path = "chatglm2-6b"
model_path = os.path.join(ROOT, model_path)
else:
# or you can add your own model here
raise NotImplementedError(f"{model} not implemented")
t = args.t
device = args.device
if t == "clear":
os.system("pkill -f fastchat")
os.system("rm ./*.log")
os.system("rm ./*.log.*")
elif t == "run":
num_gpus = len(device.split(','))
os.system(f"CUDA_VISIBLE_DEVICES={device} python -m fastchat.serve.controller &")
os.system(f"CUDA_VISIBLE_DEVICES={device} python -m fastchat.serve.model_worker --model-name '{model}' --model-path '{model_path}' --num-gpus {num_gpus} &")
os.system(f"CUDA_VISIBLE_DEVICES={device} python -m fastchat.serve.openai_api_server &")
with open("model.log", "w") as f:
f.write(model)
exit()