Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
27adb89d
Commit
27adb89d
authored
Sep 23, 2020
by
Ruoxin Sang
Committed by
A. Unique TensorFlower
Sep 23, 2020
Browse files
Force trigger python garbage collection in continuous finetuning.
PiperOrigin-RevId: 333306806
parent
0864d66e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
official/nlp/train_ctl_continuous_finetune.py
official/nlp/train_ctl_continuous_finetune.py
+8
-0
No files found.
official/nlp/train_ctl_continuous_finetune.py
View file @
27adb89d
...
...
@@ -15,6 +15,7 @@
# ==============================================================================
"""TFM continuous finetuning+eval training driver."""
import
gc
import
os
import
time
from
typing
import
Any
,
Mapping
,
Optional
...
...
@@ -145,6 +146,13 @@ def run_continuous_finetune(
train_utils
.
write_summary
(
summary_writer
,
global_step
,
summaries
)
train_utils
.
remove_ckpts
(
model_dir
)
# In TF2, the resource life cycle is bound with the python object life
# cycle. Force trigger python garbage collection here so those resources
# can be deallocated in time, so it doesn't cause OOM when allocating new
# objects.
# TODO(b/169178664): Fix cycle reference in Keras model and revisit to see
# if we need gc here.
gc
.
collect
()
if
pretrain_steps
and
global_step
.
numpy
()
>=
pretrain_steps
:
logging
.
info
(
'The global_step reaches the pretraining end. Continuous '
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment