Skip to content

Commit c29f742

Browse files
committed
Add clear_devices when exporting models
1 parent 2a03979 commit c29f742

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

dense_classifier.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ def inference(inputs, is_train=True):
488488
builder.add_meta_graph_and_variables(
489489
sess,
490490
[tag_constants.SERVING],
491+
clear_devices=True,
491492
signature_def_map={
492493
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
493494
model_signature,
@@ -575,7 +576,8 @@ def export_model(sess, saver, signature, model_path, model_version):
575576
logging.info("Export the model to {}".format(model_path))
576577
model_exporter = exporter.Exporter(saver)
577578
model_exporter.init(sess.graph.as_graph_def(),
578-
named_graph_signatures=signature)
579+
named_graph_signatures=signature,
580+
clear_devices=True)
579581
try:
580582
model_exporter.export(model_path, tf.constant(model_version), sess)
581583
except Exception as e:

sparse_classifier.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ def inference(sparse_ids, sparse_values, is_train=True):
431431
builder.add_meta_graph_and_variables(
432432
sess,
433433
[tag_constants.SERVING],
434+
clear_devices=True,
434435
signature_def_map={
435436
signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY:
436437
model_signature,
@@ -535,7 +536,8 @@ def export_model(sess, saver, signature, model_path, model_version):
535536
logging.info("Export the model to {}".format(model_path))
536537
model_exporter = exporter.Exporter(saver)
537538
model_exporter.init(sess.graph.as_graph_def(),
538-
named_graph_signatures=signature)
539+
named_graph_signatures=signature,
540+
clear_devices=True)
539541
try:
540542
model_exporter.export(model_path, tf.constant(model_version), sess)
541543
except Exception as e:

0 commit comments

Comments
 (0)