deepspeedai / deepspeedai/DeepSpeed

Suspected memory leak during zero3 training. oom eventually after several checkpoint

Open
#3,582 10 comments 0 reactions 1 assignee View on GitHub

@ShijieZZZZ is already working on this.

Since May 22, 2023.

bug training
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Hi,

I am using zero3 with latest 0.9.2 to train 8gpus in one node, and from the stat, I see memory grow a lot after each checkpoint saving.

With checking the code, I find one suspected memory leak place,
https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/engine.py#L3257
In _zero3_consolidated_16bit_state_dict, it would alloc [state_dict] local variable to collect params in rank0, and return it to parent function save_16bit_model, where it use self.checkpoint_engine.save to save it to disk.

So [state_dict] is a local variable, is it suitable to pass the param out to the parent function? would it cause some memory leak in this way?

Thx,
Lei

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.