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

Conversion from TF to ONNX stops, throwing KeyError 21 #1054

Open
jackhu3301 opened this issue Feb 3, 2023 · 0 comments
Open

Conversion from TF to ONNX stops, throwing KeyError 21 #1054

jackhu3301 opened this issue Feb 3, 2023 · 0 comments

Comments

@jackhu3301
Copy link

Pls help me. Thank you very much. I am trying to convert tf2 model to onnx using graphfile.

But got this error:

2023-02-03 15:59:30.193108: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1613] Created device /job:localhost/replica:0/task:0/device:GPU:7 with 30969 MB memory: -> device: 7, name: Tesla V100S-PCIE-32GB, pci bus id: 0000:41:00.0, compute capability: 7.0

2023-02-03 15:59:39,646 - INFO - Using tensorflow=2.11.0, onnx=1.13.0, tf2onnx=1.13.0/2c1db5
2023-02-03 15:59:39,646 - INFO - Using opset <onnx, 13>
Traceback (most recent call last):
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/convert.py", line 706, in
main()
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/convert.py", line 269, in main
model_proto, _ = _convert_common(
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/convert.py", line 164, in _convert_common
g = process_tf_graph(tf_graph, const_node_values=const_node_values,
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tfonnx.py", line 459, in process_tf_graph
main_g, subgraphs = graphs_from_tf(tf_graph, input_names, output_names, shape_override, const_node_values,
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tfonnx.py", line 474, in graphs_from_tf
ordered_func = resolve_functions(tf_graph)
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tf_loader.py", line 760, in resolve_functions
_, _, _, _, _, functions = tflist_to_onnx(tf_graph, {})
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tf_utils.py", line 441, in tflist_to_onnx
onnx_tensor = tf_to_onnx_tensor(value, name=port_name(node.name))
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tf_utils.py", line 52, in tf_to_onnx_tensor
np_data = get_tf_tensor_data(tensor)
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tf2onnx/tf_utils.py", line 70, in get_tf_tensor_data
np_data = tensor_util.MakeNdarray(tensor)
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tensorflow/python/framework/tensor_util.py", line 595, in MakeNdarray
dtype = tensor_dtype.as_numpy_dtype
File "/data/home/hujie/miniconda3/envs/py39/lib/python3.8/site-packages/tensorflow/python/framework/dtypes.py", line 98, in as_numpy_dtype
return _TF_TO_NP[self._type_enum]
KeyError: 21`

This section can be obtained by running get_version.py from util folder.

  • Python version: 3.8.13
  • ONNX version: 1.13.0
  • ONNX-TF version: 1.13.0/2c1db5
  • Tensorflow version: 2.11.0

Additional context

Have considered this issue maybe similar #299 , and also install onnx-tf, but not fix.

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant