VLLM (Virtual Large Language Model) 是由加州大学伯克利分校和斯坦福大学联合开发的高性能大语言模型推理引擎。它通过创新的PagedAttention技术和连续批处理机制,显著提升了大模型推理的效率和吞吐量。
| 特性 | VLLM | Ollama |
|---|---|---|
| 性能 | ⭐⭐⭐⭐⭐ 高性能推理,支持连续批处理 | ⭐⭐⭐ 中等性能,适合本地测试 |
| 部署复杂度 | ⭐⭐⭐ 需要一定技术背景 | ⭐⭐⭐⭐⭐ 一键部署,极简使用 |
| 扩展性 | ⭐⭐⭐⭐⭐ 支持分布式部署 | ⭐⭐ 单机部署为主 |
| 模型支持 | ⭐⭐⭐⭐ 主流大模型 | ⭐⭐⭐⭐ 多种模型格式 |
| 企业级特性 | ⭐⭐⭐⭐⭐ 完善的监控和管理 | ⭐⭐⭐ 基础功能 |
| 资源利用率 | ⭐⭐⭐⭐⭐ 高效利用GPU资源 | ⭐⭐⭐ 中等资源利用率 |
vllm serve /workspace \ --host 0.0.0.0 \ --port 8080 \ --dtype auto \ --max-model-len 8192 \ --gpu-memory-utilization 0.5 \ --tensor-parallel-size 1 \ --max-num-seqs 256 \ --enforce-eager \ --served-model-name DeepSeek-R1-0528-Qwen3-8B
参数注释说明:
curl http://localhost:8080/v1/models
参数注释说明:
json中的data.id代表模型名称curl -X POST "http://localhost:8080/v1/chat/completions" -H "Content-Type: application/json" \ -d @- <<EOF { "model": "$CNB_REPO_NAME", "messages": [{"role": "user", "content": "你好"}] } EOF
建议采用以下python脚本进行测试
import base64
import requests
import json
def test_multimodal():
# 读取并编码图片
with open('test.jpg', 'rb') as f:
image_data = f.read()
base64_image = base64.b64encode(image_data).decode('utf-8')
# 构建请求数据
payload = {
"model": "GLM-4.1V-9B-Thinking",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "图片里有什么?"
},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{base64_image}"
}
}
]
}
]
}
# 发送请求
try:
response = requests.post(
"http://localhost:8080/v1/chat/completions",
headers={"Content-Type": "application/json"},
json=payload,
timeout=300 # 5分钟超时
)
print("Status Code:", response.status_code)
print("Response:", json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
test_multimodal()