1、# 安装ModelScope工具包
pip install modelscope
# 下载量化模型(默认路径:~/.cache/modelscope/hub/)
modelscope download --model Qwen/Qwen3-8B-AWQ(需要12G显存)
或
modelscope download --model Qwen/Qwen3-1.7B
2、运行
vllm serve --model /home/用户名/.cache/modelscope/models/Qwen--Qwen3-8B-AWQ/snapshots/master
报错,提示显存不够
本机5070显卡有8G显存,改为运行1.7B模型:
vllm serve --model /home/用户名/.cache/modelscope/models/Qwen--Qwen3-1.7B/snapshots/master
还是报错,提示显存不够。
默人KV Cache为40960个token,占显存约4.3G,而这块RTX5070显卡的8G显存中只能给KV Cache分配2.1G
限制token长度为4096,再次运行:
vllm serve --model /home/用户名/.cache/modelscope/models/Qwen--Qwen3-1.7B/snapshots/master --max-model-len 4096
测试:
curl http://localhost:8000/v1/completions -H "Content-Type: application/json" -d '{
"model": "/home/用户名/.cache/modelscope/models/Qwen--Qwen3-1.7B/snapshots/master",
"prompt": "大模型是什么?<think>\n",
"max_tokens": 1024,
"temperature": 0
}'
看到了正常的答案
O了!