2
模型讨论区
DeepSeek-R1模型部署教程
2025-02-10 12:06:28
707

DeepSeek-R1

资源说明

运行该项目需要4x8x64GB显存。硬件资源为K100-AI.

获取项目代码

git clone http://developer.sourcefind.cn/codes/modelzoo/deepseek-r1_pytorch.git

环境准备

1、获取docker镜像

docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.3.0-ubuntu22.04-dtk24.04.3-py3.10

2、创建并运行docker容器

docker run --shm-size 500g --network=host --name=dpskr1 --privileged --device=/dev/kfd --device=/dev/dri --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v <获取的项目代码地址>:/home/ -v /opt/hyhal:/opt/hyhal:ro -it <上一步获取的docker镜像ID> bash

注意: 可以使用     docker images  获取相应的镜像ID。

3、依赖项安装

cd /home/inference
pip install -r requirements.txt

模型准备

1、下载模型

有两种方式可下载模型分别是使用SCNet及huggingface下载,具体方式分别为

git clone http://113.200.138.88:18080/aimodels/deepseek-ai/DeepSeek-R1.git
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download deepseek-ai/DeepSeek-R1 --local-dir DeepSeek-R1

2、模型转换

cd inference python fp8_cast_bf16.py --input-fp8-hf-path /path/to/fp8_weights --output-bf16-hf-path /path/to/DeepSeek-R1-bf16

注意,这里的/path/to/fp8_weights就是 下载模型  部分得到的模型.

3、模型划分

python convert.py --hf-ckpt-path /path/to/DeepSeek-R1-bf16 --save-path /path/to/DeepSeek-R1-Demo --n-experts 256 --model-parallel 32

4、文件复制

cp /path/to/fp8_weights/*.json /path/to/DeepSeek-R1-Demo

运行

export NCCL_ALGO=Ring
export NCCL_PROTO=Simple

torchrun --nnodes 4 --nproc-per-node 8 --node-rank $RANK --master-addr $ADDR generate.py --ckpt-path /path/to/DeepSeek-V3-Demo --config configs/config_671B.json --interactive --temperature 0.7 --max-new-tokens 200

运行效果

attachmentId-image.png

全部评论(7)
只看楼主
网
网友25KVHV
3楼
Writing input of failed execution to /tmp/err_execute_model_input_20250411-182610.pkl. 模型启动后,请求一次崩溃
2025/4/11
P
panhb
回复 @网友25KVHV
麻烦发下报错,以及启动和请求命令吧
2025/4/14
网
网友iSBbaB
2楼

执行转换精度的脚本产生了如下报错,看样子是python3.7.9版本太老导致的,functools 模块并不包含 cached_property,想问下你转换精度是在物理机上直接转换的吗,以及用的python版本是多少呢。

python3 fp8_cast_bf16.py --input-fp8-hf-path /home/appuser/Deepseek-v3 --output-bf16-hf-path /home/appuser/Deepseek-v3-bf16

Traceback (most recent call last):

File "fp8_cast_bf16.py", line 10, in <module>

from kernel import weight_dequant

File "/home/appuser/kernel.py", line 4, in <module>

import triton

File "/usr/local/lib64/python3.7/site-packages/triton/__init__.py", line 8, in <module>

from .runtime import (

File "/usr/local/lib64/python3.7/site-packages/triton/runtime/__init__.py", line 1, in <module>

from .autotuner import (Autotuner, Config, Heuristics, OutOfResources, autotune, heuristics)

File "/usr/local/lib64/python3.7/site-packages/triton/runtime/autotuner.py", line 7, in <module>

from ..testing import do_bench

File "/usr/local/lib64/python3.7/site-packages/triton/testing.py", line 8, in <module>

from . import language as tl

File "/usr/local/lib64/python3.7/site-packages/triton/language/__init__.py", line 6, in <module>

from .standard import (

File "/usr/local/lib64/python3.7/site-packages/triton/language/standard.py", line 3, in <module>

from ..runtime.jit import jit

File "/usr/local/lib64/python3.7/site-packages/triton/runtime/jit.py", line 10, in <module>

from functools import cached_property

ImportError: cannot import name 'cached_property' from 'functools' (/usr/lib64/python3.7/functools.py)
2025/3/14
网
网友iSBbaB
回复 @网友iSBbaB
我已通过放在容器中进行精度转换解决该问题
2025/3/17
索
索大喝旺仔
1楼

下载的模型要分别放在四个机器上吗?

如可判断网络组网是OK的呢
2025/2/24
A
ANYA
回复 @索大喝旺仔

1、可以4台机器使用共享存储,或者分别在每台机器上下载

2、可以测试下几台机器之间通信是否正常
2025/2/25
索
索大喝旺仔
回复 @索大喝旺仔
谢谢哦~
2025/2/27
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据