第七十七篇-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
  }'
相关推荐
代码山河9 小时前
Python就业方向全解析:后端、爬虫、数据分析、AI你选哪个?
python·学习·架构·教程·面向对象·项目
在世修行9 小时前
智学文枢:题目流水线
python·多线程·状态机·pyside
C^h9 小时前
c++ string
开发语言·c++
raindayinrain10 小时前
c++高性能--原子操作,无锁编程,操作顺序
开发语言·c++·性能优化
梯度下降者10 小时前
零基础入门Python 爬虫
爬虫·python·数据分析·入门指南·webcrawler
学逆向的10 小时前
C++ 合并命名空间
开发语言·c++·网络安全
Zhao-Jichao10 小时前
VS2026 打包 C++ 程序生成 EXE,借助 Installer Project 扩展工具
开发语言·c++
学逆向的11 小时前
C 局部静态变量
c语言·开发语言·网络安全
大都督会赢的11 小时前
C++第一节课
开发语言·c++
“AI国潮设计-小江”11 小时前
【AIGC实战】Python+Stable Diffusion打造“英歌舞财神”IP,解锁“马到成功”等爆款情绪营销文案设计
开发语言·人工智能·python·prompt·aigc