Skip to content

pt -> engine convert #6563

Closed
Closed

Description

@ONNONS

Search before asking

Question

Jetson nano environment
I am trying to change engine from pt
I entered "python3 export.py --weights XXX.pt --include engine"
error has occured

export: data=data/coco128.yaml, weights=['doe3.pt'], imgsz=[640, 640], batch_size=1, device=cpu, half=False, inplace=False, train=False, optimize= False, int8=False, dynamic=False, simplify=False, opset=12, verbose=False, workspace=4, nms=False, agnostic_nms=False, topk_per_class=100, topk_all=100, iou_thres=0.45, conf_thres=0.25, include=['engine']
YOLOv5 🚀 2022-2-5 torch 1.7.0 CPU

Fusing layers...
Model Summary: 190 layers, 5233482 parameters, 0 gradients, 14.4 GFLOPs

PyTorch: starting from doe3.pt with output shape (1, 24000, 7) (10.7 MB)

ONNX: starting export with onnx 1.10.2...
ONNX: export failure: Unsupported ONNX opset version: 13

TensorRT: starting export with TensorRT 8.0.1.6...

TensorRT: export failure: export running on CPU but must be on GPU, i.e. python export.py --device 0
Traceback (most recent call last):
File "export.py", line 526, in
main(opt)
File "export.py", line 521, in main
run(**vars(opt))
File "/home/.local/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
return func(*args, **kwargs)
File "export.py", line 479, in run
LOGGER.info(f'\nExport complete ({time.time() - t:.2f}s)'
IndexError: list index out of range

Additional

No response

Activity

  1. zhiqwang commented on Feb 8, 2022

    @zhiqwang
    Contributor

    Seems that the PyTorch 1.7.0 version is a little outdated, it is better to upgrade the current PyTorch version to 1.9+ or use the intermediate exported ONNX model to convert to the TensorRT engine.

  2. glenn-jocher commented on Feb 8, 2022

    @glenn-jocher
    Member

    @ONNONS error message you showed is self explanatory:

    TensorRT: export failure: export running on CPU but must be on GPU, i.e. python export.py --device 0
    
  3. glenn-jocher commented on Feb 8, 2022

    @glenn-jocher
    Member

    @ONNONS good news 😃! We've improved ✅ error handling for zero-export cases in PR #6569. You should now see a clearer error message on export failure, i.e.:

    Screenshot 2022-02-08 at 12 15 16

    To receive this update:

    • Git – git pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
    • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
    • Notebooks – View updated notebooks Open In Colab Open In Kaggle
    • Docker – sudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

    Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

  4. njustczr commented on Feb 11, 2022

    @njustczr

    on jetson nano,
    image
    so i can not export *.pt file to *.engine file

  5. zhiqwang commented on Feb 11, 2022

    @zhiqwang
    Contributor

    YOLOv5's default TensorRT inference relies on the CUDA version of PyTorch:

    self.binding_addrs['images'] = int(im.data_ptr())

    I guess that you can replace the data binding here to pycuda to reduce this dependency.

  6. ONNONS commented on Feb 11, 2022

    @ONNONS
    Author

    YOLOv5's default TensorRT inference relies on the CUDA version of PyTorch:

    self.binding_addrs['images'] = int(im.data_ptr())

    I guess that you can replace the data binding here to pycuda to reduce this dependency.

    What version should I use? Pytorch , cuda, tensorrt, torchvision . . . Etc

  7. zhiqwang commented on Feb 12, 2022

    @zhiqwang
    Contributor

    What version should I use? Pytorch , cuda, tensorrt, torchvision . . . Etc

    Hi @ONNONS , The minimum version requirements for PyTorch and torchvision should be 1.8 and 0.9, check out the official guide to install them on your CUDA device https://pytorch.org/get-started/locally/

    For myself, I suggest to install the latest version of TensorRT (8.2.x), the new version of TensorRT will give you a completely different user experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions