Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an error message for copress/freeze #1319

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion deepmd/entrypoints/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ def compress(
# stage 2: freeze the model
log.info("\n\n")
log.info("stage 2: freeze the model")
freeze(checkpoint_folder=checkpoint_folder, output=output, node_names=None)
try:
freeze(checkpoint_folder=checkpoint_folder, output=output, node_names=None)
except GraphTooLargeError as e:
raise RuntimeError(
"The uniform step size of the tabulation's first table is %f, "
"which is too small. This leads to a very large graph size, "
"exceeding protobuf's limitation (2 GB). You should try to "
"increase the step size." % step
) from e

def _check_compress_type(model_file):
try:
Expand Down
9 changes: 8 additions & 1 deletion deepmd/entrypoints/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,14 @@ def freeze(

# We retrieve the protobuf graph definition
graph = tf.get_default_graph()
input_graph_def = graph.as_graph_def()
try:
input_graph_def = graph.as_graph_def()
except google.protobuf.message.DecodeError as e:
raise GraphTooLargeError(
"The graph size exceeds 2 GB, the hard limitation of protobuf."
" Then a DecodeError was raised by protobuf. You should "
"reduce the size of your model."
) from e
nodes = [n.name for n in input_graph_def.node]

# We start a session and restore the graph weights
Expand Down
2 changes: 1 addition & 1 deletion deepmd/utils/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class GraphTooLargeError(Exception):
pass
"""The graph is too large, exceeding protobuf's hard limit of 2GB."""

class GraphWithoutTensorError(Exception):
pass
Expand Down