Skip to content

Commit

Permalink
keep model_avg on cpu
Browse files Browse the repository at this point in the history
  • Loading branch information
yaozengwei committed May 6, 2022
1 parent 70634d5 commit c3bb032
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 0 additions & 4 deletions egs/librispeech/ASR/pruned_transducer_stateless4/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,6 @@ def run(rank, world_size, args):
model = DDP(model, device_ids=[rank])
model.device = device

if rank == 0:
model_avg.to(device)
model_avg.device = device

optimizer = Eve(model.parameters(), lr=params.initial_lr)

scheduler = Eden(optimizer, params.lr_batches, params.lr_epochs)
Expand Down
4 changes: 3 additions & 1 deletion icefall/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,5 +467,7 @@ def average_state_dict(
uniqued_names = list(uniqued.values())
for k in uniqued_names:
state_dict_1[k] *= weight_1
state_dict_1[k] += state_dict_2[k] * weight_2
state_dict_1[k] += (
state_dict_2[k].to(device=state_dict_1[k].device) * weight_2
)
state_dict_1[k] *= scaling_factor

0 comments on commit c3bb032

Please sign in to comment.