通过VLLM部署Qwen3-14B-AWQ
云平台: 优云智算 --目前新用户免费送额度,提供全开放公网地址
Ubuntu-22.04-nvidia
NVIDIA GeForce RTX 3090 24G
#基础环境
conda create -n llm python=3.12 -y
pip install torch==2.7.1 torchaudio==2.7.1 torchvision==0.22.1 -f https://mirrors.aliyun.com/pytorch-wheels/cu121
pip install vllm==0.10.0 -i Simple Index
#检查环境
(llm) root@10-60-209-167:/usr/llm-model/Qwen3-14B-AWQ# vllm --version
INFO 08-12 12:46:55 [__init__.py:235] Automatically detected platform cuda.
0.10.0
#下载模型
pip install modelscope
modelscope download --model Qwen/Qwen3-14B-AWQ --local_dir /opt/models/Qwen3-14B-AWQ
pip install autoawq -i https://mirrors.aliyun.com/pypi/simple
#启动 vLLM 服务(OpenAI API 模式)
python -m vllm.entrypoints.openai.api_server \
--model /opt/models/Qwen3-14B-AWQ \ # HuggingFace模型名或本地模型路径
--quantization awq \ # 量化方式(若加载 AWQ 模型)
--trust-remote-code \ # 信任远程代码(Qwen 需要)
--host 0.0.0.0 \ # 监听所有 IP
--port 8888 # 端口号
#测试运行
curl http://localhost:8888/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "/opt/models/Qwen3-14B-AWQ",
"prompt": "介绍你自己",
"max_tokens": 100
}'
#测试python文件 client_chat.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
from openai import OpenAI
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--ask", type=str, help="要提问的问题")
args = parser.parse_args()
client = OpenAI(
base_url="http://localhost:8888/v1", # vLLM 服务地址
api_key="none" # vLLM 不需要密钥
)
response = client.chat.completions.create(
model="/opt/models/Qwen3-14B-AWQ",
messages=[
{"role": "system", "content": "你是一位AI机器人,通俗易懂且简洁的回复问题,语气需要俏皮可爱活泼,直接回答问题,不要输出任何思考过程或<think>标签,可以使用表情符号."},
{"role": "user", "content": f'{args.ask} /no_think'}
],
extra_body={"chat_template_kwargs":{"enable_thinking":False}},
max_tokens=16384
)
print(response.choices[0].message.content)
python client_chat.py --ask "你是谁?"
直接通过项目调用可以参考官网: 快速入门 — vLLM
更多推荐


所有评论(0)