update vllm

This commit is contained in:
Wenjie Zhang 2024-09-24 11:58:13 +08:00
parent b6abb2c8e7
commit fcbb11c8d5
2 changed files with 26 additions and 3 deletions

View File

@ -1,9 +1,14 @@
MODEL=Meta-Llama-3-8B-Instruct
if [ -z "$1" ]; then
echo "Error: No argument provided. Please specify a model name."
exit 1
fi
if [ "$1" = "llama" ]; then
CUDA_VISIBLE_DEVICES=0,1 python -m vllm.entrypoints.openai.api_server \
CUDA_VISIBLE_DEVICES=0 python -m vllm.entrypoints.openai.api_server \
--model="/hdd/zwj/models/meta-llama/$MODEL" \
--tensor-parallel-size 2 \
--tensor-parallel-size 1 \
--trust-remote-code \
--device auto \
--gpu-memory-utilization 0.98 \
@ -28,4 +33,4 @@ fi
# kv-cache-dtype kv 缓存存储的数据类型。如果为“auto”则将使用模型默认的数据类型。CUDA 11.8及以上版本 支持 fp8 =fp8_e4m3 和 fp8_e5m2。ROCm AMD GPU 支持 fp8 =fp8_e4m3
# served-model-name 对外提供的API中的模型名称
# host 监听的网络地址0.0.0.0表示所有网卡的所有IP127.0.0.1表示仅限本机
# port API服务的端口
# port API服务的端口

18
vllm/test_vllm.py Normal file
View File

@ -0,0 +1,18 @@
from openai import OpenAI
# Set OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "EMPTY"
openai_api_base = "http://localhost:8080/v1"
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
chat_response = client.chat.completions.create(
model="llama",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me a joke."},
]
)
print("Chat response:", chat_response)