Skip to content

Commit 8c5a60d

Browse files
Merge pull request #213 from david-thrower/209-add-garbage-collection-between-models
Added garbage collection between sub - trial models in the NAS loop.
2 parents 6cea4e8 + be8ef5a commit 8c5a60d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Python application
55

66
on:
77
push:
8-
branches: [ "main", "205-new-branch-for-testing-searialization" ]
8+
branches: [ "main", "209-add-garbage-collection-between-models" ]
99

1010
permissions:
1111
contents: read

cerebros/simplecerebrosrandomsearch/simple_cerebros_random_search.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# from cmdutil.cmdutil import run_command
1414
from multiprocessing import Process, Lock
1515
import os
16+
from gc import collect
17+
1618

1719
# import optuna
1820
# from optuna.pruners import BasePruner
@@ -480,6 +482,8 @@ def run_moity_permutations(self, spec, subtrial_number, lock):
480482
model_graph_file=model_graph_file,
481483
train_data_dtype=self.train_data_dtype
482484
)
485+
tf.keras.backend.clear_session()
486+
collect()
483487
nnf.materialize()
484488
nnf.compile_neural_network()
485489
neural_network = nnf.materialized_neural_network
@@ -515,7 +519,11 @@ def run_moity_permutations(self, spec, subtrial_number, lock):
515519
index=False,
516520
header=self.needs_oracle_header,
517521
mode='a')
522+
518523
self.needs_oracle_header = False
524+
neural_network = None
525+
tf.keras.backend.clear_session()
526+
collect()
519527
return 0
520528

521529
def run_random_search(self):

0 commit comments

Comments
 (0)