forked from sophgo/LLM-TPU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·68 lines (60 loc) · 1.7 KB
/
run.sh
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
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -ex
# Args
parse_args() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--model)
model="$2"
shift 2
;;
--arch)
arch="$2"
shift 2
;;
*)
echo "Invalid option: $key" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
}
# Mapping
declare -A model_to_demo=(
["chatglm2-6b"]="ChatGLM2"
["chatglm3-6b"]="ChatGLM3"
["llama2-7b"]="Llama2"
["qwen-7b"]="Qwen"
["qwen1.5-1.8b"]="Qwen1_5"
["wizardcoder-15b"]="WizardCoder"
)
# Process Args
parse_args "$@"
# Check Version
compare_date="20240110"
if [ $arch == "pcie" ]; then
extracted_date=$(cat /proc/bmsophon/driver_version | grep -o 'release date: [0-9]\{8\}' | grep -o '[0-9]\{8\}')
elif [ $arch = "soc" ]; then
extracted_date_str=$(uname -a | grep -oP 'SMP \K[A-Za-z]+\s[A-Za-z]+\s\d+\s\d+:\d+:\d+\s[A-Za-z]+\s\d+' | sed 's/HKT //')
extracted_date=$(date -d "$extracted_date_str" '+%Y%m%d')
fi
if [ "$extracted_date" -lt "$compare_date" ]; then
>&2 echo -e "Your driver is \033[31moutdated\033[0m. Please update your driver."
exit 1
else
echo "Driver date is $extracted_date, which is up to date. Continuing..."
fi
# Check Model Name
if [[ ! ${model_to_demo[$model]} ]]; then
>&2 echo -e "Error: Invalid name $model, the input name must be \033[31mchatglm3-6b|chatglm2-6b|llama2-7b|qwen-7b|qwen1.5-1.8b|wizardcoder-15b\033[0m"
exit 1
fi
# Compile
pushd "./models/${model_to_demo[$model]}"
./run_demo.sh
popd