第七十七篇-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
  }'
相关推荐
九转成圣13 小时前
实战记录:用 Java 拼接长图/网格图,我踩了哪些坑?
java·开发语言
&&Citrus13 小时前
【CPN 学习笔记(三)】—— Chap3 CPN ML 编程语言 上半部分 3.1 ~ 3.3
笔记·python·学习·cpn·petri网
lzhdim13 小时前
SQL 入门 9:SQL 高级子查询:ANY、EXISTS 与多位置应用
java·开发语言·数据库·sql·mysql
Dream of maid13 小时前
Python(11) 进程与线程
开发语言·python
财经资讯数据_灵砚智能14 小时前
基于全球经济类多源新闻的NLP情感分析与数据可视化(日间)2026年4月7日
大数据·人工智能·python·信息可视化·语言模型·自然语言处理·ai编程
cici1587414 小时前
非线性模型预测控制(NMPC)基于CasADi的MATLAB实现
开发语言·matlab
独特的螺狮粉14 小时前
开源鸿蒙跨平台Flutter开发:量子态波函数坍缩系统-波动力学与概率云渲染架构
开发语言·flutter·华为·架构·开源·harmonyos
Yqlqlql14 小时前
# Python : Word 文档标注工具
python
冰暮流星14 小时前
javascript之dom访问属性
开发语言·javascript·dubbo
lsx20240614 小时前
SQL Auto Increment 自动增长
开发语言