Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit b0a9d80

Browse files
Haoran Lifacebook-github-bot
authored andcommitted
remove move_state_dict_to_gpu, which is causing cuda oom (#1367)
Summary: Pull Request resolved: #1367 I keep getting cuda oom in this load_best_model stage, move_state_dict_to_gpu and model.cuda() are not both needed. Looks like it will double gpu memory this way. Reviewed By: anchit Differential Revision: D21725316 fbshipit-source-id: 70b5761a25afb19da7f44a3fead37b36d0e122da
1 parent 2fec533 commit b0a9d80

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pytext/trainers/trainer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ def load_best_model(self, state: TrainingState):
333333
if cuda.CUDA_ENABLED:
334334
# Move current model to CPU to avoid multiple models in GPU memory
335335
state.model.cpu()
336-
state.model.load_state_dict(
337-
self.move_state_dict_to_gpu(state.best_model_state)
338-
)
336+
state.model.load_state_dict(state.best_model_state)
339337
# Move model back to GPU
340338
state.model.cuda()
341339
else:

0 commit comments

Comments
 (0)