第七十七篇-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
  }'
相关推荐
2401_871492853 分钟前
Vue.js监听器watch利用回调函数处理级联下拉框数据联动
jvm·数据库·python
FreakStudio16 分钟前
亲测可用!可本地部署的 MicroPython 开源仿真器
python·单片机·嵌入式·面向对象·并行计算·电子diy·电子计算机
:12119 分钟前
java基础
java·开发语言
SilentSamsara1 小时前
Python 环境搭建完整指南:从下载安装到运行第一个程序
开发语言·python
小短腿的代码世界1 小时前
Qt文件系统与IO深度解析:从QFile到异步文件操作
开发语言·qt
zhoutongsheng1 小时前
C#怎么实现Swagger文档 C#如何在ASP.NET Core中集成Swagger自动生成API文档【框架】
jvm·数据库·python
harder3212 小时前
RMP模式的创新突破
开发语言·学习·ios·swift·策略模式
.5483 小时前
## Sorting(排序算法)
python·算法·排序算法
ydmy3 小时前
注意力机制(个人理解)
pytorch·python·深度学习
jinanwuhuaguo3 小时前
OpenClaw工程解剖——RAG、向量织构与“记忆宫殿”的索引拓扑学(第十三篇)
android·开发语言·人工智能·kotlin·拓扑学·openclaw