---
title: 仅在某个Device上保存Checkpoint数据-昇腾社区
description: 分布式训练场景下，如果用户只希望在某个device上保存checkpoint数据，而不希望在其他device上保存checkpoint数据。
keywords: 分布式训练;checkpoint数据
url: https://www.hiascend.com/document/caselibrary/detail/topic_0000001343431065
section: (其他)
---

# 仅在某个Device上保存Checkpoint数据-昇腾社区

URL: https://www.hiascend.com/document/caselibrary/detail/topic_0000001343431065
描述: 分布式训练场景下，如果用户只希望在某个device上保存checkpoint数据，而不希望在其他device上保存checkpoint数据。
关键词: 分布式训练;checkpoint数据

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

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

仅在某个Device上保存Checkpoint数据

仅在某个Device上保存Checkpoint数据

2022/09/20

742

问题信息

| 问题来源 | 产品大类 | 产品子类 | 关键字 |
| --- | --- | --- | ---|
| 官方 | 模型训练 | TensorFlow | 分布式训练、checkpoint数据 |

#### 问题现象描述

分布式训练场景下，如果用户只希望在某个device上保存checkpoint数据，而不希望在其他device上保存checkpoint数据。

#### 原因分析

修改训练脚本。

#### 解决措施

按照如下方法修改训练脚本：

TensorFlow原始代码：

```
self._classifier=tf.estimator.Estimator(
  model_fn=cnn_model_fn,
  model_dir=self._model_dir,
  config=tf.estimator.RunConfig(
      save_checkpoints_steps=50 if hvd.rank() == 0 else None,
      keep_checkpoint_max=1))
```

迁移后的代码：

```
self._classifier=NPUEstimator(
  model_fn=cnn_model_fn,
  model_dir=self._model_dir,
  config=tf.estimator.NPURunConfig(
      save_checkpoints_steps=50 if get_rank_id() == 0 else 0,
      keep_checkpoint_max=1))
```

本页内容

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