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

export.py export onnx for gpu failed #2365

Closed
sveits6 opened this issue Mar 4, 2021 · 5 comments
Closed

export.py export onnx for gpu failed #2365

sveits6 opened this issue Mar 4, 2021 · 5 comments
Labels

Comments

@sveits6
Copy link

sveits6 commented Mar 4, 2021

when export onnx model for gpu,i change the export.py :
图片
but export failed:

图片

how to solve it?

@sveits6 sveits6 changed the title export.py export onnx for gpu fa export.py export onnx for gpu failed Mar 4, 2021
@glenn-jocher
Copy link
Member

@sveits6 fro GPU export you may want to see this PR: #2297

@sveits6
Copy link
Author

sveits6 commented Mar 5, 2021

@glenn-jocher sorry,the problem is not be solved

@toretak
Copy link
Contributor

toretak commented Mar 5, 2021

@sveits6
I guess you should use device cuda:0 when you loading model.

Successfully tested on code from #2297

$ python models/export.py --device 0 --weights ../../detection/yolo5/yolov5/yolo20210116.pt 
Namespace(batch_size=1, device='0', dynamic=False, img_size=[640, 640], skip_last_layer=False, weights='../../detection/yolo5/yolov5/yolo20210116.pt')
YOLOv5 v4.0-96-ge3f5bdb torch 1.7.1 CUDA:0 (GeForce GTX 1650 with Max-Q Design, 3914.1875MB)

Fusing layers... 
Model Summary: 316 layers, 21929304 parameters, 0 gradients, 52.8 GFLOPS

Starting TorchScript export with torch 1.7.1...
/git/yolov5/.venv/lib/python3.8/site-packages/torch/jit/_trace.py:934: TracerWarning: Encountering a list at the output of the tracer might cause the trace to be incorrect, this is only valid if the container structure does not change based on the module's inputs. Consider using a constant container instead (e.g. for `list`, use a `tuple` instead. for `dict`, use a `NamedTuple` instead). If you absolutely need this and know the side effects, pass strict=False to trace() to allow this behavior.
  module._c._create_method_from_trace(
TorchScript export success, saved as ../../detection/yolo5/yolov5/yolo20210116.torchscript.pt

Starting ONNX export with onnx 1.8.1...
ONNX export success, saved as ../../detection/yolo5/yolov5/yolo20210116.onnx
CoreML export failure: No module named 'coremltools'

Export complete (7.68s). Visualize with https://github.com/lutzroeder/netron.

@sveits6
Copy link
Author

sveits6 commented Mar 6, 2021

@glenn-jocher @toretak
thank you very much for your reply!
when "model.model[-1].export = True" it works, but "model.model[-1].export = False" it failed。
if must make "model.model[-1].export = True" , how can i get the final result from the 3 feature maps?

@github-actions
Copy link
Contributor

github-actions bot commented Apr 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

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

No branches or pull requests

3 participants