4*A100 部署 deepseek-r1-671B

部署deepseek-r1-671B

使用 4*A100 部署 deepseek-r1-671b-1.58bit 大模型。

环境

  • ubuntu22.04LTS
  • cuda 12.2.0

要求

  • 内存: 256GB及以上
  • 显存: 256GB及以上(160G可以跑起来,但对于长上下文容易oom),这里是A100 80G * 4

vllm

CUDA_VISIBLE_DEVICES=0,1,2,3 /data/miniconda3/envs/llm_py311-8/bin/python -m vllm.entrypoints.openai.api_server \
--port 8001 --served-model-name Qwen2-7B-Instruct \
--model /your/671B/model/path.gguf

失败,提示错误:

python3.11/site-packages/transformers/modeling_gguf_pytorch_utils.py", line 399, in load_gguf_checkpoint
    raise ValueError(f"GGUF model with architecture {architecture} is not supported yet.")
ValueError: GGUF model with architecture deepseek2 is not supported yet.

github上面看到vllm暂不支持deepseek-r1-671B,有各种问题,暂时放弃

llama.cpp

准备阶段

cuda需要12.0及以上,我的cuda版本是12.2.0(用docker了),我在11.5上面编译失败(可能和GPU的驱动编译方式有关,没细研究),GPU 是 A100 * 4

模型下载参考:https://www.ollama.com/SIGJNF/deepseek-r1-671b-1.58bit
或者下载:https://hf-mirror.com/unsloth/DeepSeek-R1-GGUF/tree/main/DeepSeek-R1-UD-IQ1_M

  • 拉取容器
    docker pull nvcr.io/nvidia/cuda:12.2.0-cudnn8-devel-ubuntu22.04 # 可能网络会有点问题

  • 运行容器

    docker run -it -d --name  llama_cpp --gpus all \
       -v /data/work/Star/.ollama/:/work/ollama/ \
       -v /data/work/Star/llama.cpp:/work/llama.cpp/ \
       -p 28000:8000 \
       -p 27860:7860 \
       -e TZ='Asia/Shanghai' \
       nvcr.io/nvidia/cuda:12.2.0-cudnn8-devel-ubuntu22.04
    
  • 进入容器
    docker exec -it llama_cpp env LANG=C.UTF-8 /bin/bash

##拉取代码
git clone https://github.com/ggml-org/llama.cpp

编译GPU版本

cd llama.cpp
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j16

运行服务

cd build/bin/
CUDA_VISIBLE_DEVICES=0,1,2,3  ./llama-server \
-m /path_to_model.gguf \
--port 7860 \
--cache-type-k q4_0  --threads 64  --prio 2  --temp 0.6 \
--ctx-size 8192 \
--seed 3407 \
--n-gpu-layers 1600

或者:

CUDA_VISIBLE_DEVICES=0,1,2,3 ./llama-server \
-m /path_to_model.gguf \
--port 7860 \
--host 0.0.0.0 \
-c 16384 \
-np 4 \
--n-gpu-layers 15000

更多参数配置参考:
https://github.com/ggml-org/llama.cpp/blob/master/examples/server/README.md

并发测试

5个并发:

curl --request POST     --url http://localhost:17861/completion     --header "Content-Type: application/json"     --data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 12}' &
curl --request POST     --url http://localhost:17861/completion     --header "Content-Type: application/json"     --data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 102}' &
curl --request POST     --url http://localhost:17861/completion     --header "Content-Type: application/json"     --data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 112}' &
curl --request POST     --url http://localhost:17861/completion     --header "Content-Type: application/json"     --data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 42}' &
curl --request POST     --url http://localhost:17861/completion     --header "Content-Type: application/json"     --data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 32}' &

这里测试了不同输入长度及上下文长度。

参考

  1. https://github.com/ggml-org/llama.cpp
  2. https://github.com/ggml-org/llama.cpp/blob/master/examples/server/README.md
  3. https://hf-mirror.com/unsloth/DeepSeek-R1-GGUF
  4. https://www.ollama.com/SIGJNF/deepseek-r1-671b-1.58bit
### 部署 Deepseek-R1 671B 所需的硬件和软件配置 #### 硬件需求 对于希望在本地环境中部署 Deepseek-R1 671B 模型的情况,尤其是采用无蒸馏但量化的方式时,推荐的硬件配置如下: - **处理器 (CPU)**:建议使用高性能多核 CPU,如 Intel Xeon 或 AMD EPYC 处理器系列。这类处理器能够提供足够的计算能力来支持模型推理过程中的复杂运算。 - **内存 (RAM)**:至少配备 512GB DDR4 RAM,考虑到该模型参数量庞大,在加载及运行期间需要大量内存空间。 - **存储设备**:SSD 存储介质必不可少,容量应不少于 2TB NVMe SSD。快速读写速度有助于加速数据交换效率,减少等待时间。 - **图形处理单元 (GPU)**:虽然可以仅依靠 CPU 进行推理,但对于如此大规模的语言模型而言,拥有强大的 GPU 支持会显著提升性能表现。NVIDIA A100 Tensor Core GPUs 是理想的选择之一,其具备出色的浮点运算能力和大容量显存[^1]。 #### 软件环境搭建 为了顺利安装并启动 Deepseek-R1 671B 模型,还需要准备相应的软件依赖项: - **操作系统**:Linux 发行版(例如 Ubuntu LTS),因为大多数机器学习框架都基于 Linux 开发,并且社区资源更丰富。 - **Python 版本**:确保 Python 3.8 及以上版本已正确安装于系统之中。这是由于部分深度学习库可能不再兼容旧版本解释器。 - **PyTorch/Transformers 库**:作为构建与训练神经网络的核心工具包,这两个开源项目提供了丰富的预训练模型接口以及高效的张量操作函数集。通过 pip 工具即可轻松获取最新稳定发行版。 - **CUDA Toolkit 和 cuDNN SDK**:当选用 NVIDIA 显卡时,则必须同步下载匹配当前驱动程序版本号的 CUDA 平台开发套件及其配套优化算法库 cuDNN,从而充分发挥 GPU 加速特性[^2]。 ```bash pip install torch torchvision torchaudio transformers --upgrade ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

szZack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值