Mask RCNN ONNX export KeyError: '_new_empty_tensor_op'
See original GitHub issueSystem Ubuntu 18.04 Torch 1.4.0 Torchvision 0.5.0 pip installed
I have tried the examples you give in the tutorial:
import torch
import torchvision
model = torchvision.models.detection.maskrcnn_resnet50_fpn(pretrained=True)
model.eval()
model=model.cuda()
test_data = torch.rand(1,3,300,400).cuda()
traced_model = torch.jit.trace(model, test_data)
But got this error:
/usr/local/lib/python3.6/dist-packages/torch/tensor.py:461: RuntimeWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won’t change the number of iterations executed (and might lead to errors or silently give incorrect results). ‘incorrect results).’, category=RuntimeWarning) /usr/local/lib/python3.6/dist-packages/torchvision/models/detection/roi_heads.py:392: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor). return torch.tensor(M + 2 * padding).to(torch.float32) / torch.tensor(M).to(torch.float32) /usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset9.py:1951: UserWarning: Exporting aten::index operator of advanced indexing in opset 11 is achieved by combination of multiple ONNX operators, including Reshape, Transpose, Concat, and Gather. If indices include negative values, the exported graph will produce incorrect results. “If indices include negative values, the exported graph will produce incorrect results.”) /usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py:716: UserWarning: ONNX export failed on custom operator torchvision::_new_empty_tensor_op because torch.onnx.symbolic_opset11._new_empty_tensor_op does not exist. Have you registered your symbolic function with torch.onnx.register_custom_op_symbolic(symbolic_name, symbolic_fn)? .format(ns, op_name, opset_version, op_name)) Traceback (most recent call last): File “test.py”, line 9, in <module> torch.onnx.export(model, x, “mask_rcnn.onnx”, opset_version = 11) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/init.py”, line 148, in export strip_doc_string, dynamic_axes, keep_initializers_as_inputs) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py”, line 66, in export dynamic_axes=dynamic_axes, keep_initializers_as_inputs=keep_initializers_as_inputs) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py”, line 416, in _export fixed_batch_size=fixed_batch_size) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py”, line 296, in _model_to_graph fixed_batch_size=fixed_batch_size, params_dict=params_dict) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py”, line 135, in _optimize_graph graph = torch._C._jit_pass_onnx(graph, operator_export_type) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/init.py”, line 179, in _run_symbolic_function return utils._run_symbolic_function(*args, **kwargs) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/utils.py”, line 717, in _run_symbolic_function symbolic_fn = sym_registry.get_registered_op(op_name, ns, opset_version) File “/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_registry.py”, line 91, in get_registered_op return _registry[(domain, version)][opname] KeyError: ‘_new_empty_tensor_op’
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
@fmassa thanks, raised a new issue here #2111 , please have a look.
@ResByte can you create a new issue? Your error seems unrelated to the original issue