132  
查询码: 00000637
gemma-4-12B-it模型部署(SDK 4.5.0 + x86)
专家 2026年07月07日 发布 ,于 2026年07月07日 编辑


一、测试条件

项目

SDK/Driver版本

4.5.0(社区版)

GPU型号

Iluvatar MR-V100 

模型所需最低GPU数量

1张(推荐2张)

CPU架构

x86_64

模型类别

LLM(Gemma4 Unified)

量化方式

BF16(原生权重)

vLLM版本

v0.23.0 + vllm_iluvatar 0.23.0 plugin


二、创建容器

1、获取镜像

拉取命令:

docker pull registry.iluvatar.com.cn:10443/vllm_plugin/corex_vllm_plugin:0.23.0-corex-4.5.0.20260619-ubuntu24.04-py3.12-x86_64-v1

2、创建容器

docker run -dit -v /usr/src:/usr/src -v /lib/modules:/lib/modules -v /dev:/dev -v /data:/data -v /home:/home --network=host --name=gemma-4-12B-it --ipc=host --privileged --cap-add=ALL --pid=host  registry.iluvatar.com.cn:10443/vllm_plugin/corex_vllm_plugin:0.23.0-corex-4.5.0.20260619-ubuntu24.04-py3.12-x86_64-v1  /bin/bash

3、进入容器

docker exec -it gemma-4-12B-it /bin/bash

三、启动服务

1、下载权重

推荐使用 ModelScope:

pip install modelscope

modelscope download --model google/gemma-4-12B-it --local_dir /data/models/gemma-4-12B-it

2、启动模型

容器内执行:

# 单卡启动

vllm serve /data/models/gemma-4-12B-it \
--host 0.0.0.0 \
--port 8000 \
--trust-remote-code \
--tensor-parallel-size 1 \
--gpu-memory-utilization 0.90 \
--max-model-len 8192 \
--max-num-seqs 64

# 双卡(推荐)

vllm serve /data/models/gemma-4-12B-it \
--host 0.0.0.0 --port 8000 \
--trust-remote-code \
--tensor-parallel-size 2 \
--gpu-memory-utilization 0.90 \
--max-model-len 8192

四、curl请求测试

普通curl请求测试:

#使用v1 chat接口

curl -s http://127.0.0.1:8000/v1/chat/completions   -H 'Content-Type: application/json'   -d '{
    "model": "/data/models/gemma-4-12B-it",
    "messages": [
      {"role": "user", "content": "你好!请简单介绍一下自己。"}
    ],
    "max_tokens": 128,
    "temperature": 0
  }'


或只要一个答案的请求:

curl -s http://127.0.0.1:8000/v1/chat/completions   -H 'Content-Type: application/json'   -d '{"model":"/data/models/gemma-4-12B-it","messages":[{"role":"user","content":"1+1等于几?"}],"max_tokens":32,"temperature":0}'   | python3 -c "import sys,json;print(json.load(sys.stdin)['choices'][0]['message']['content'])"


注意事

1. 社区版部署前必须先安装 SDK ≥ 4.5.0,不能使用 4.4.0 SDK

2. 模型 config.json 中 model_type 为 gemma4_unified,使用 Gemma4UnifiedForConditionalGeneration 架构

3. GPU 显存占用约 22.73 GiB(TP=1, BF16),建议单卡 32GB 以上

4. 首次启动 vLLM 会进行 torch.compile 编译和 CUDA Graph 捕获,耗时约 3-5 分钟

5. CUDA KV Cache 容量约 31,764 tokens(4.67 GiB),支持约 3.88x 并发(max-model-len=8192)

6. VLLM_ENFORCE_CUDA_GRAPH 在 vLLM 0.23.0 中已弃用,vLLM 会自动启用 CUDA Graph

7. 模型权重 ~23GB,下载前确保剩余磁盘空间 ≥ 50GB

8. 双卡 TP=2 可支持更大的 max-model-len 或更高并发


笔记



  目录
    天数智芯知识库系统 -V 5.2.7 -wcp