链载Ai

标题: DeepSeek-V3-0324 本地部署,vLLM和SGLang的方法 [打印本页]

作者: 链载Ai    时间: 前天 20:41
标题: DeepSeek-V3-0324 本地部署,vLLM和SGLang的方法


ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">DeepSeek-V3-0324 发布了之后,折腾了几天,把踩过的坑记录下来,也给正在折腾本地部署的朋友避避雷。

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">本人水平有限,如有错误的地方欢迎指正

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;display: table;padding: 0px 0.2em;color: rgb(255, 255, 255);background: rgb(15, 76, 129);">模型下载

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">DeepSeek-V3-0324发布的当天

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">官方在huggingface上上传了所有的模型参数

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">地址如下

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">https://huggingface.co/deepseek-ai/DeepSeek-V3-0324

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;color: rgb(63, 63, 63);">

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">为了图方便,我通常到modelscope上去下载

ingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;letter-spacing: 0.1em;color: rgb(63, 63, 63);">在3月25日上午,modelscope上已经发布了这个模型,当时ReadME都还没有上传,模型介绍都是空的

我直接下载了这个模型之后部署试用,发现输出中存在各种乱码

一开始还以为使用的推理引擎有问题,新模型的适配可能还没有做好。

但是看到各大卖token的厂商已经完成了部署,也没人说这个问题,而且社区里也没有相关的issue

那么只有两种可能性

  1. 1. 我下载过程中出了问题,大概率是我的问题
  2. 2. 这个仓库的模型有问题

但600多G的模型,我也没精力删了之后再重新下载一遍试试了。

可以看到来自官方的模型是642G,而本次下来的模型只有634G

所以其他500多位跟我下载了同一个仓库的朋友,如果你能看到这篇文章,希望能帮到你吧。

到了3月25日中午左右

modelscope上更新了DeepSeek官方仓库的DeepSeek-V3-0324

重新下载后再部署就正常了,以后还是要认准官方的东西。

按照DeepSeek官方文档的介绍可以看到

0324的模型结构与原DeepSeek-V3完全相同

那么,原则上来说我们只需要把原来部署DeepSeek-V3/R1的启动脚本拿过来

直接改个模型目录就可以正常部署了!

部署环境

我这边的环境配置如下

机器:2台 8 * H100 80G

模型:Deepseek-V3-0324 685B FP8

vLLM

这里我用的还是与上篇文章中所写到的vllm/vllm-openai:v0.8.1

吞吐量破10000tokens/s,VLLM 0.8.1版本驱动下的Deepseek-r1 671B

阿里云版本

dockerpullregistry.cn-hangzhou.aliyuncs.com/dongfangzan/vllm-openai:v0.8.1

启动脚本如下

# 节点1
bash run_cluster.sh \
vllm/vllm-openai \
ip_of_head_node \
--head \
/path/to/the/huggingface/home/in/this/node \
-e VLLM_HOST_IP=ip_of_this_node \
--privileged -e NCCL_IB_HCA=mlx5 #此处省略IB配置
# 节点2
bash run_cluster.sh \
vllm/vllm-openai \
ip_of_head_node \
--worker \
/path/to/the/huggingface/home/in/this/node \
-e VLLM_HOST_IP=ip_of_this_node \
--privileged -e NCCL_IB_HCA=mlx5 #此处省略IB配置

启动成功之后使用docker exec -it node bash

这个版本在启动之前在两个节点上分别执行

pipinstallpyarrowpandas

然后再执行下面的命令

VLLM_ATTENTION_BACKEND=FLASHMLA \
VLLM_USE_V1=1 \
vllm serve /root/.cache/huggingface/hub/deepseek-ai/DeepSeek-V3-0324 \
--served-model-name deepseek-v3-0324 \ # 模型名称
--enable-prefix-caching \
--max-model-len 131072 \
--gpu-memory-utilization 0.95 \
--tensor-parallel-size 8 \
--pipeline-parallel-size 2 \
--enable-chunked-prefill \
--enable-expert-parallel \
--max_num_batched_tokens 32768 \
--trust-remote-code \
--block-size 64 \
--port 8000

还是解释一下几个关键参数

  1. 1. VLLM_ATTENTION_BACKEND=FLASHMLA --block-size 64,开启FlashMLA
  2. 2. --enable-expert-parallel,开启EP

VLLM_TEST_ENABLE_EP=1 这个参数已经在此版本中被移除,开启是无效的,也是感谢各位大佬的提醒

SGLang

接下来是SGLang的部署方式

使用lmsysorg/sglang:v0.4.4.post1-cu124这个版本的镜像

为了方便下载,我上传了一个镜像到阿里云上

registry.cn-hangzhou.aliyuncs.com/dongfangzan/sglang:v0.4.4.post1-cu124

其次注意你可能需要去下载一个适用于DeepSeek-V3-0324的草稿模型来启动MTP

这会大幅提升你模型的输出速度,这个在前面的文章中我们也测试过,所以尽量还是开启这个能力

地址在这里:https://huggingface.co/lmsys/DeepSeek-V3-0324-NextN

SGLang的部署方式相对vLLM更简单,分别在两个节点上执行下面的指令

# 节点1
docker run \
--gpus all \ # 使用所有 GPUs
--shm-size 512g \ # 设置共享内存大小为 512GB
--network=host \ # 使用主机网络
-v /your/path/of/model:/root/.cache/huggingface \ # 挂载 Hugging Face 缓存目录
--name sglang_multinode1 \ # 容器名称
-d \ # 后台运行
--ipc=host \ # 使用主机的 IPC 命名空间
--restart always \ # 容器退出时总是重启
--privileged \ # 以特权模式运行
-e NCCL_IB_HCA=mlx5 # 省略后续IB配置
-e SGL_ENABLE_JIT_DEEPGEMM=1 \ # 启用 JIT DeepGEMM
lmsysorg/sglang:v0.4.4.post1-cu124 \ # Docker 镜像名称和标签
python3 -m sglang.launch_server \
--model-path /root/.cache/huggingface/hub/deepseek-ai/DeepSeek-V3-0324 \ # 模型路径
--served-model-name deepseek-v3-0324 \ # 服务模型名称
--tp 16 \ # 模型并行度
--enable-torch-compile \
--enable-flashinfer-mla \ # 启用 FlashInfer MLA
--speculative-algo EAGLE \
--speculative-num-steps 3 \
--speculative-eagle-topk 1 \
--speculative-num-draft-tokens 4 \
--speculative-draft /root/.cache/huggingface/hub/deepseek-ai/DeepSeek-V3-0324-NextN \ # 投机草稿模型路径
--dist-init-addr 10.0.41.2:20000 \ # 分布式初始化地址
--nnodes 2 \ # 节点数
--node-rank 0 \ # 节点排名
--trust-remote-code \ # 信任远程代码
--host 0.0.0.0 \ # 服务主机地址
--port 8000 # 服务端口
# 节点2
docker run \
.... # 省略相同的参数
--node-rank 1 \ # 节点排名

关于工具调用

与DeepSeek-R1不同的是,DeepSeek-V3是支持工具调用的

但是上述两个推理引擎截止到目前为止目前还没有完成这个特性的开发

所以着急使用DeepSeek-V3来测试Agent能力的朋友

可能还是到官网上去充点钱调用官方的API来测试吧

后续的变化我这边也会持续跟踪,感谢你看到这里


相关阅读
真·生产级满血版Deepseek-r1 671B部署实例
真·生产级满血版Deepseek-r1 671B部署实例篇2-后续问题、调优以及压测
性能大幅提升!生产环境DeepSeek-R1 671B 3月压测和优化纪实

更小尺寸比肩最强!阿里最新QwQ-32B与Deepseek-r1 671B、Deepseek-r1 32B实测对比

深入QwQ,工具调用、压测和调优

满血版 Deepseek-r1 性能再突破!到底还有多少性能空间可以挖掘?

吞吐量破10000tokens/s,VLLM 0.8.1版本驱动下的Deepseek-r1 671B






欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5