NVIDIA-AI-IOT / CUDA-PointPillars

A project demonstrating how to use CUDA-PointPillars to deal with cloud points data from lidar.
Apache License 2.0
502 stars 148 forks source link

Could not export onnx. #72

Closed Domwis-IR closed 1 year ago

Domwis-IR commented 1 year ago

I tried export.py but could not do it because it didn't get the right input. 2022-10-28 04:02:25,943 INFO ==> Loading parameters from checkpoint ./pointpillar_7728.pth to CPU

Traceback (most recent call last):
  File "exporter.py", line 150, in <module>
    main()
  File "exporter.py", line 134, in main
    output_names = ['cls_preds', 'box_preds', 'dir_cls_preds'], # the model's output names
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/__init__.py", line 365, in export
    export_modules_as_functions,
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 178, in export
    export_modules_as_functions=export_modules_as_functions,
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 1097, in _export
    dynamic_axes=dynamic_axes,
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 737, in _model_to_graph
    graph, params, torch_out, module = _create_jit_graph(model, args)
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 611, in _create_jit_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args)
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/onnx/utils.py", line 527, in _trace_and_get_graph_from_model
    model, args, strict=False, _force_outplace=False, _return_inputs_states=True
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/jit/_trace.py", line 1179, in _get_trace_graph
    outs = ONNXTracedModule(f, strict, _force_outplace, return_inputs, _return_inputs_states)(*args, **kwargs)
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/jit/_trace.py", line 134, in forward
    self._force_outplace,
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/jit/_trace.py", line 120, in wrapper
    outs.append(self.inner(*trace_inputs))
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/rjh1016/anaconda3/envs/openpcdet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1118, in _slow_forward
    result = self.forward(*input, **kwargs)
**TypeError: forward() missing 1 required positional argument: 'batch_dict'**

I guess the model architecture is still same with the OpenPCDet. But I don't know what to do first to export onnx from this file. My torch version is 1.12.1+cu102, cuda version is 11.3 and onnx version is 1.12.0

rjwb1 commented 1 year ago

@Domwis-IR I am working on the same issue. Did you solve it?

rjwb1 commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule

Domwis-IR commented 1 year ago

Thank you so much with your reply. I will try too!

jrb-cobot commented 1 year ago

@rjwb1 could you share your Dockerfile?

rjwb1 commented 1 year ago

@jrb-cobot find here, I had to modify it slightly as I have a customised workflow but hope this helps

https://github.com/NVIDIA-AI-IOT/CUDA-PointPillars/pull/77/commits/4bcb9246e5bf93f33f8c7792d5b4f369f0f754b2

https://github.com/NVIDIA-AI-IOT/CUDA-PointPillars/pull/77

The-wind-rises-2023 commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule @rjwb1 I built the image using the dockerfile you provided, and used the container created from the image . But the command "python exporter.py --ckpt pointpillar_7728.pth"could not do it.Could you provide some help?

rjwb1 commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule @rjwb1 I built the image using the dockerfile you provided, and used the container created from the image . But the command "python exporter.py --ckpt pointpillar_7728.pth"could not do it.Could you provide some help?

Could you provide more information about the issue? Perhaps the traceback

The-wind-rises-2023 commented 1 year ago

@rjwb1 Thanks for your replytation! I uesd your dockerfile for builting container and then solved problem.Thanks!

QiXueZhong commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule @rjwb1 I built the image using the dockerfile you provided, and used the container created from the image . But the command "python exporter.py --ckpt pointpillar_7728.pth"could not do it.Could you provide some help?

Could you provide more information about the issue? Perhaps the traceback

May I ask what environment your docker is in? x86 or Xavier/Orin?

QiXueZhong commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule @rjwb1 I built the image using the dockerfile you provided, and used the container created from the image . But the command "python exporter.py --ckpt pointpillar_7728.pth"could not do it.Could you provide some help?

Could you provide more information about the issue? Perhaps the traceback

image the wrong message

rjwb1 commented 1 year ago

This docker file is for x86. Please check the README.md inside the docker directory for usage

The-wind-rises-2023 commented 1 year ago

@Domwis-IR this was due to using the wrong version of PCDet. To solve this I created a docker container with torch 1.8.1 and PCDet at the HEAD reference by the submodule @rjwb1 I built the image using the dockerfile you provided, and used the container created from the image . But the command "python exporter.py --ckpt pointpillar_7728.pth"could not do it.Could you provide some help?

Could you provide more information about the issue? Perhaps the traceback

image the wrong message

You can modify the last two lines in your Dockerfile(add "-c"),like this: ENTRYPOINT ["/bin/bash", "-c"] CMD ["/bin/bash", "-c"]

jrb-cobot commented 1 year ago

I'm still working on this issue. I'd like to keep to the current version of OpenPCDet so that I can use the latest models and features. If anyone has made progress using version 0.6.0+, please let me know.

Anutlet commented 5 months ago

I'm still working on this issue. I'd like to keep to the current version of OpenPCDet so that I can use the latest models and features. If anyone has made progress using version 0.6.0+, please let me know.

Do you have any progress? I can't find the difference that led to the problem between v0.5 and v0.6. I'm looking forward to your reply. Thank you very much!

MenciusYates commented 2 months ago

I'm still working on this issue. I'd like to keep to the current version of OpenPCDet so that I can use the latest models and features. If anyone has made progress using version 0.6.0+, please let me know.

Do you have any progress? I can't find the difference that led to the problem between v0.5 and v0.6. I'm looking forward to your reply. Thank you very much!

I can't find the difference that led to the problem between v0.5 and v0.6. I'm looking forward to your reply, too.