第七十七篇-V100+llama-cpp-python-server+Qwen3-30B+GGUF

环境

复制代码
系统:CentOS-7
CPU : E5-2680V4 14核28线程
内存:DDR4 2133 32G * 2
显卡:Tesla V100-32G【PG503】 (水冷)
驱动: 535
CUDA: 12.2

环境

复制代码
[第七十六篇-V100+llama-cpp-python+Qwen3-30B+GGUF-CSDN博客](https://blog.csdn.net/hai4321/article/details/157739271)

安装依赖

bash 复制代码
pip install sentencepiece -i https://mirrors.cloud.tencent.com/pypi/simple
pip install uvicorn -i https://mirrors.cloud.tencent.com/pypi/simple
pip install starlette -i https://mirrors.cloud.tencent.com/pypi/simple
pip installfastapi -i https://mirrors.cloud.tencent.com/pypi/simple
pip install fastapi -i https://mirrors.cloud.tencent.com/pypi/simple
pip install sse_starlette -i https://mirrors.cloud.tencent.com/pypi/simple
pip install starlette_context -i https://mirrors.cloud.tencent.com/pypi/simple
pip install pydantic_settings -i https://mirrors.cloud.tencent.com/pypi/simple

如有需要再自己安装

代码

server.py

bash 复制代码
#!/usr/bin/env python3
# server.py
from llama_cpp import Llama
from llama_cpp.server.app import create_app
from llama_cpp.server.settings import Settings
import uvicorn

MODEL_PATH = "/models/GGUF_LIST/Qwen3-30B-A3B-Thinking-2507-Q4_K_M.gguf"

settings = Settings(
    model=MODEL_PATH,
    n_ctx=32768,
    n_gpu_layers=65,          # V100 32GB
    n_threads=28,
    n_batch=512,
    chat_format="qwen",       # Qwen3 专用 chat template
    host="0.0.0.0",
    port=8000,
    verbose=False,
)

app = create_app(settings)

if __name__ == "__main__":
    uvicorn.run(app, host=settings.host, port=settings.port)

运行

bash 复制代码
python server.py

访问

bash 复制代码
# 1. 查看可用模型
curl http://localhost:8000/v1/models

# 2. 非流式对话
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-next-80b-instruct-Q4_K_M.gguf",
    "messages": [
      {"role": "system", "content": "你是一个乐于助人的AI助手"},
      {"role": "user", "content": "1+1等于几?"}
    ],
    "max_tokens": 100,
    "temperature": 0.7
  }' | jq .

# 3. 流式对话(推荐用于长文本)
curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3-next-80b-instruct-Q4_K_M.gguf",
    "messages": [{"role": "user", "content": "请写一首关于春天的诗"}],
    "stream": true
  }'
相关推荐
荣码5 小时前
GraphRAG:普通RAG只能回答"点"的问题,我踩了4个坑才搞懂
java·python
金銀銅鐵15 小时前
[Python] 基于欧几里得算法,实现分数约分计算器
python·数学
Lyn_Li17 小时前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现
python·kaggle·比赛复盘·金融预测
小九九的爸爸1 天前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
阿耶同学1 天前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
花酒锄作田2 天前
Pydantic校验配置文件
python
hboot2 天前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络
ZhengEnCi2 天前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi2 天前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽2 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry