Skip to content

Commit

Permalink
fix the config file unclose (NVIDIA#268)
Browse files Browse the repository at this point in the history
We have a runtime checker, and it report: 
```
ResourceWarning: unclosed file <_io.TextIOWrapper name='deepspeed_config_13B.json' mode='r' encoding='utf-8'>
  open(args.deepspeed_config, 'r', encoding='utf-8'))
```
Because when json.load(open()), it never close.
  • Loading branch information
zhangsheng377 authored Oct 24, 2023
1 parent 54e6c2c commit 796866f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions megatron/training.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def print_datetime(string):
'''
def _create_ds_config_dict():
args = get_args()
ds_config_dict = json.load(
open(args.deepspeed_config, 'r', encoding='utf-8'))
with open(args.deepspeed_config, 'r', encoding='utf-8') as config_file:
ds_config_dict = json.load(config_file)

if args.universal_checkpoint:
ds_config_dict["checkpoint"] = {"load_universal": True}
Expand Down

0 comments on commit 796866f

Please sign in to comment.