|
2 | 2 | set -e |
3 | 3 |
|
4 | 4 | # vLLM Server Startup Script |
5 | | -# Usage: ./start_vllm.sh [config.yaml|model_path] [additional_args...] |
| 5 | +# Usage: ./start_vllm.sh config.yaml [additional_args...] |
6 | 6 |
|
7 | | -show_usage() { |
8 | | - echo "Usage: $0 [config.yaml|model_path] [additional_args...]" |
| 7 | +if [ $# -eq 0 ]; then |
| 8 | + echo "Usage: $0 config.yaml [additional_args...]" |
9 | 9 | echo "" |
10 | | - echo "Examples:" |
11 | | - echo " # Using YAML config file:" |
| 10 | + echo "Example:" |
12 | 11 | echo " $0 vllm_config.yaml" |
13 | | - echo "" |
14 | | - echo " # Using model path with args:" |
15 | | - echo " $0 ./outputs/lora-out --lora-modules lora_name=./outputs/lora-out" |
16 | | - echo " $0 NousResearch/Llama-3.2-1B --max-model-len 4096" |
17 | | - echo " $0 ./outputs/merged-model --port 8000" |
18 | | - echo "" |
19 | | - echo "YAML config example:" |
20 | | - echo " model: ./outputs/my-model" |
21 | | - echo " max_model_len: 32768" |
22 | | - echo " gpu_memory_utilization: 0.95" |
23 | | - echo " port: 8000" |
24 | | - echo " host: 0.0.0.0" |
25 | | -} |
26 | | - |
27 | | -if [ $# -eq 0 ]; then |
28 | | - show_usage |
29 | 12 | exit 1 |
30 | 13 | fi |
31 | 14 |
|
32 | | -INPUT="$1" |
33 | | -shift # Remove first arg, keep the rest |
| 15 | +CONFIG_FILE="$1" |
| 16 | +shift # Remove config file from args, keep additional args |
34 | 17 |
|
35 | | -# Check if input is a YAML file |
36 | | -if [[ "$INPUT" == *.yaml ]] || [[ "$INPUT" == *.yml ]]; then |
37 | | - if [ ! -f "$INPUT" ]; then |
38 | | - echo "β Config file not found: $INPUT" |
39 | | - exit 1 |
40 | | - fi |
41 | | - |
42 | | - echo "π Starting vLLM server with config file..." |
43 | | - echo "π Config: $INPUT" |
44 | | - |
45 | | - # Extract key info from YAML for display |
46 | | - if command -v python3 >/dev/null 2>&1; then |
47 | | - MODEL=$(python3 -c " |
48 | | -import yaml |
49 | | -try: |
50 | | - with open('$INPUT', 'r') as f: |
51 | | - config = yaml.safe_load(f) |
52 | | - print(config.get('model', 'Not specified')) |
53 | | -except: |
54 | | - print('Could not parse config') |
55 | | -" 2>/dev/null || echo "Could not parse config") |
56 | | - |
57 | | - PORT=$(python3 -c " |
58 | | -import yaml |
59 | | -try: |
60 | | - with open('$INPUT', 'r') as f: |
61 | | - config = yaml.safe_load(f) |
62 | | - print(config.get('port', 8000)) |
63 | | -except: |
64 | | - print('8000') |
65 | | -" 2>/dev/null || echo "8000") |
66 | | - |
67 | | - HOST=$(python3 -c " |
68 | | -import yaml |
69 | | -try: |
70 | | - with open('$INPUT', 'r') as f: |
71 | | - config = yaml.safe_load(f) |
72 | | - print(config.get('host', '0.0.0.0')) |
73 | | -except: |
74 | | - print('0.0.0.0') |
75 | | -" 2>/dev/null || echo "0.0.0.0") |
76 | | - |
77 | | - echo "π Model: $MODEL" |
78 | | - echo "π Server will be available at: http://$HOST:$PORT" |
79 | | - fi |
80 | | - echo "π§ Additional args: $*" |
81 | | - echo "" |
82 | | - |
83 | | - # Start vLLM with config file (using dedicated venv) |
84 | | - /opt/vllm-venv/bin/python -m vllm.entrypoints.openai.api_server \ |
85 | | - --config "$INPUT" \ |
86 | | - "$@" |
87 | | - |
88 | | -else |
89 | | - # Treat as model path (legacy mode) |
90 | | - MODEL_PATH="$INPUT" |
91 | | - |
92 | | - echo "π Starting vLLM server..." |
93 | | - echo "π Model: $MODEL_PATH" |
94 | | - echo "π§ Additional args: $*" |
95 | | - echo "π Server will be available at: http://0.0.0.0:8000" |
96 | | - echo "" |
97 | | - |
98 | | - # Start vLLM with the provided model and any additional arguments (using dedicated venv) |
99 | | - /opt/vllm-venv/bin/python -m vllm.entrypoints.openai.api_server \ |
100 | | - --model "$MODEL_PATH" \ |
101 | | - --host 0.0.0.0 \ |
102 | | - --port 8000 \ |
103 | | - "$@" |
| 18 | +if [ ! -f "$CONFIG_FILE" ]; then |
| 19 | + echo "β Config file not found: $CONFIG_FILE" |
| 20 | + exit 1 |
104 | 21 | fi |
| 22 | + |
| 23 | +echo "π Starting vLLM server..." |
| 24 | +echo "π Config: $CONFIG_FILE" |
| 25 | +echo "π§ Additional args: $*" |
| 26 | +echo "" |
| 27 | + |
| 28 | +# Start vLLM with config file (using dedicated venv) |
| 29 | +/opt/vllm-venv/bin/vllm serve --config "$CONFIG_FILE" "$@" |
0 commit comments