---
title: 20节点160卡跑baichuan-7B模型报错out of memory，但2节点16卡能跑通-昇腾社区
description: 硬件配置: 问题现象：20节点160卡跑baichuan-7B模型报错out of memory，如下图所示，dp/mp/pp设置为40/1/4；2节点16卡能跑通，dp/mp/pp分别设置为8/1/2。
keywords: 20节点160卡
url: https://www.hiascend.com/document/caselibrary/detail/case_9523
section: (其他)
---

# 20节点160卡跑baichuan-7B模型报错out of memory，但2节点16卡能跑通-昇腾社区

URL: https://www.hiascend.com/document/caselibrary/detail/case_9523
描述: 硬件配置: 问题现象：20节点160卡跑baichuan-7B模型报错out of memory，如下图所示，dp/mp/pp设置为40/1/4；2节点16卡能跑通，dp/mp/pp分别设置为8/1/2。
关键词: 20节点160卡

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

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

20节点160卡跑baichuan-7B模型报错out of memory，但2节点16卡能跑通

20节点160卡跑baichuan-7B模型报错out of memory，但2节点16卡能跑通

2024/02/22

989

问题信息

| 问题来源 | 产品大类 | 产品子类 | 关键字 |
| --- | --- | --- | ---|
| 官方 | 模型训练 | MindSpore | 20节点160卡 |

#### 问题现象描述

硬件配置:

问题现象：20节点160卡跑baichuan-7B模型报错out of memory，如下图所示，dp/mp/pp设置为40/1/4；2节点16卡能跑通，dp/mp/pp分别设置为8/1/2。

#### 原因分析

parallel_config中optimizer_shard未打开。

MindSpore版本不支持optimizer_shard。

#### 排查方法

1.查看mindformers中的run_baichuan_7b.yaml配置文件，查看optimizer_shard为True。

2.将MindSpore版本升级到2.0，cann升级到c85，仍然有该问题。

#### 解决措施

查看run_baichuan_7b.yaml中hidden_size为4096，其不能被dp整除，导致优化器切分未开，重新设置dp（能整除hidden_size，如32）的值，或者加上context.set_auto_parallel_context(optimizer_weight_shard_size=8)，即使不能被dp整除，也能被8整除。

本页内容

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