---
title: 训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipe
description: 训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipeline stages 4 should be less than device_num 16.  ms版本：1.9.1 开源代码路径：https://gitee.com/mindspore/mind
keywords: 训练GPT2-13B;GPT2LMHEADMoel
url: https://www.hiascend.com/document/caselibrary/detail/case_9528
section: (其他)
---

# 训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipe

URL: https://www.hiascend.com/document/caselibrary/detail/case_9528
描述: 训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipeline stages 4 should be less than device_num 16.  ms版本：1.9.1 开源代码路径：https://gitee.com/mindspore/mind
关键词: 训练GPT2-13B;GPT2LMHEADMoel

昇腾文档 [了解详情](https://www.hiascend.com/document)

故障案例 [了解详情](https://www.hiascend.com/document/caselibrary)

训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipeline stages 4 should be less than device_num 16.

训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipeline stages 4 should be less than device_num 16.

2024/02/22

854

问题信息

| 问题来源 | 产品大类 | 产品子类 | 关键字 |
| --- | --- | --- | ---|
| 官方 | 模型训练 | MindSpore | 训练GPT2-13B、GPT2LMHEADMoel |

#### 问题现象描述

训练GPT2-13B大模型时报错ValueError: GPT2LMHEADMoel:The product of the data parallel 4, model parallel 4 pipeline stages 4 should be less than device_num 16.

ms版本：1.9.1

开源代码路径：https://gitee.com/mindspore/mindformers/tree/dev [了解详情](https://gitee.com/mindspore/mindformers/tree/dev)

#### 原因分析

可能是run_gpt2_13b.yaml文件中data_parallel,model_parallel,pipeline_stage等参数设置不合理导致。

#### 排查方法

确认run_gpt2_13b.yaml文件中data_parallel,model_parallel,pipeline_stage设置是否符合要求:dp*mp*pp要小于总卡数，micro_batch_num要大于等于pp。num_layers被pp整除，num_heads和embedding_size也要被mp整除

#### 解决措施

1.data_parallel* model_parallel *pipeline_stage要小于总卡数;

2.model_parallel的值往data_parallel上分，同时batch_size尽量大一点(一般4/8/12等)，16卡建议pipeline_stage为2，32卡建议pipeline_stage为4；

本页内容

- 问题信息
- 问题现象描述
- 原因分析
- 排查方法
- 解决措施
