cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
452 Views
Registered: ‎07-17-2019

freeze_graph error

I am getting an error while creating frozen graph. 

Tensorflow ver. : 1.12.0

Had both Python(2.7.16) and Python3(3.5.2) installed.

DNNDK ver. : 3.1

Following is my freeze graph script and error message.

Freeze graph script:

freeze_graph \
    --input_graph=./model/saved_model.pb \
    --input_checkpoint=./model/checkpoints/gnn_ckpt.data-00000-of-00001 \
    --input_binary=true \
    --output_graph=./model/frozen_graph.pb \
    --output_node_names=edge_output

Following is the error message.

/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
WARNING:tensorflow:From /harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py:127: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
W1201 12:34:03.836834 139924142143232 deprecation.py:323] From /harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py:127: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
2019-12-01 12:34:04.073305: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 AVX512F FMA
2019-12-01 12:34:04.095555: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3500000000 Hz
2019-12-01 12:34:04.096239: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x4364b00 executing computations on platform Host. Devices:
2019-12-01 12:34:04.096277: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
2019-12-01 12:34:04.097876: W tensorflow/core/util/tensor_slice_reader.cc:95] Could not open ./model/checkpoints/gnn_ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?
Traceback (most recent call last):
  File "/harddisk1/xxxx/.local/bin/freeze_graph", line 11, in <module>
    sys.exit(run_main())
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py", line 487, in run_main
    app.run(main=my_main, argv=[sys.argv[0]] + unparsed)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/absl/app.py", line 299, in run
    _run_main(main, args)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/absl/app.py", line 250, in _run_main
    sys.exit(main(argv))
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py", line 486, in <lambda>
    my_main = lambda unused_args: main(unused_args, flags)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py", line 378, in main
    flags.saved_model_tags, checkpoint_version)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py", line 361, in freeze_graph
    checkpoint_version=checkpoint_version)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/tools/freeze_graph.py", line 164, in freeze_graph_with_def_protos
    reader = pywrap_tensorflow.NewCheckpointReader(input_checkpoint)
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 636, in NewCheckpointReader
    return CheckpointReader(compat.as_bytes(filepattern))
  File "/harddisk1/xxxx/.local/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 648, in __init__
    this = _pywrap_tensorflow_internal.new_CheckpointReader(filename)
tensorflow.python.framework.errors_impl.DataLossError: Unable to open table file ./model/checkpoints/gnn_ckpt.data-00000-of-00001: Data loss: not an sstable (bad magic number): perhaps your file is in a different file format and you need to use a different restore operator?

 

Is this the checkpoint file issue, or something else? Thanks!

0 Kudos
3 Replies
Highlighted
Moderator
Moderator
423 Views
Registered: ‎03-27-2013

Re: freeze_graph error

Hi @lzhao ,

 

Are you using Keras to train the model?

Here is what I did to change keras model into freezed pb file:

https://github.com/gewuek/flower_classification_dnndk_v1/blob/master/x86/freeze_model.py

And in that resposity I also attached all the movement from training to deployment. Hope that can help.

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Newbie
Newbie
359 Views
Registered: ‎12-02-2019

Re: freeze_graph error

Hi Jason,

Thanks for the response.

We did not use Keras to train this model. 

Following are the packages used:


import argparse
import logging
import os
import sys

import yaml
import json
import tensorflow as tf

0 Kudos
Highlighted
Moderator
Moderator
330 Views
Registered: ‎03-27-2013

Re: freeze_graph error

Hi @lzhao1 ,

 

If so maybe you can refer to this one: https://github.com/Xilinx/Edge-AI-Platform-Tutorials/tree/master/docs/MNIST_tf

Best Regards,
Jason
-----------------------------------------------------------------------------------------------
Please mark the Answer as "Accept as solution" if the information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
-----------------------------------------------------------------------------------------------
0 Kudos