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

Error when converting checkpoint to ONNX #362

Open
gigasurgeon opened this issue Mar 15, 2023 · 4 comments
Open

Error when converting checkpoint to ONNX #362

gigasurgeon opened this issue Mar 15, 2023 · 4 comments

Comments

@gigasurgeon
Copy link

gigasurgeon commented Mar 15, 2023

I am getting this error when I am trying to convert checkpoint to ONNX.

torch version = 1.13.1+cu116

python3 convert_to_onnx.py /vmdata/amitsingh/workspace/z2/DB/experiments/seg_detector/my_custom.yaml /vmdata/amitsingh/workspace/z2/DB/outputs/workspace/DB/SegDetectorModel-seg_detector/deformable_resnet50/L1BalanceCELoss/model/final output.onnx


verbose: True
Initializing log dir for workspace/SegDetectorModel-seg_detector/deformable_resnet50/L1BalanceCELoss
/vmdata/amitsingh/workspace/z2/dataset_download_from_deeplabel_and_convert_to_TD500_format/DBnet_TD500_format_dataset
Resumed from /vmdata/amitsingh/workspace/z2/DB/outputs/workspace/DB/SegDetectorModel-seg_detector/deformable_resnet50/L1BalanceCELoss/model/final
Traceback (most recent call last):
  File "convert_to_onnx.py", line 81, in <module>
    main()
  File "convert_to_onnx.py", line 23, in main
    Demo(experiment, experiment_args, cmd=args).inference()
  File "convert_to_onnx.py", line 75, in inference
    torch.onnx.export(model.model.module, img, self.output_path, input_names=['input'],
  File "/vmdata/amitsingh/.local/lib/python3.8/site-packages/torch/onnx/utils.py", line 504, in export
    _export(
  File "/vmdata/amitsingh/.local/lib/python3.8/site-packages/torch/onnx/utils.py", line 1529, in _export
    graph, params_dict, torch_out = _model_to_graph(
  File "/vmdata/amitsingh/.local/lib/python3.8/site-packages/torch/onnx/utils.py", line 1115, in _model_to_graph
    graph = _optimize_graph(
  File "/vmdata/amitsingh/.local/lib/python3.8/site-packages/torch/onnx/utils.py", line 605, in _optimize_graph
    _C._jit_pass_peephole(graph, True)
IndexError: Argument passed to at() was not in the map.
@minh132
Copy link

minh132 commented Oct 5, 2023

Have you fixed this error yet? @gigasurgeon

@minh132
Copy link

minh132 commented Oct 6, 2023

@MhLiao can you help me fix this error

@GermanDeer
Copy link

GermanDeer commented Oct 12, 2023

@MhLiao can you help me fix this error

pytorch/pytorch#104067

Try installing PyTorch 2.1.0 with CUDA 11.8, and use argument autograd_inlining=False:

torch.onnx.export(model.model.module, img, self.output_path, input_names=['input'],
                              output_names=['output'], dynamic_axes=dynamic_axes,
                              verbose=False, opset_version=12, autograd_inlining=False)

It helps with this error, but there is another one:
issue

@Obezyan0941
Copy link

Here is the solution that worked for me with autograd_inlining=False option:
open-mmlab/mmagic#63

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

4 participants