Closed timarnoldev closed 4 months ago
@timarnoldev Hi! A segmentation fault can occur due to issues related to memory access, possibly caused by model loading, image processing, or other memory management operations. To help diagnose the issue, I have a few suggestions and questions:
Check if demo/detect/detect.cpp
Runs Correctly:
Can you confirm if the detect.cpp
file in your demo runs without encountering segmentation faults? This will help determine if the issue is specifically within the code snippet you provided or elsewhere.
Check ONNX Export for EfficientNMS Plugin: Verify whether your exported ONNX model includes the EfficientNMS plugin. This is crucial for correct model inference. If not, please refer to this issue for YOLOv9 or this pull request for YOLOv10 on how to include the EfficientNMS plugin during export.
Provide the Complete Demo Code: It would be helpful to see the complete code for your demo, especially the parts involving model loading, data input, prediction, and output. This will allow for a more thorough examination of potential issues.
If possible, please share the full project code or key parts of it so I can assist you further in resolving this issue.
Thanks for your quick response. The provided example also crashes with my specific model file. At the same time my code works with the provided yolov8s file. I guess something is wrong with my engine file.
I used the ultralytics cli to convert from .pt -> .onnx with this command
yolo export model=best.pt format=onnx
Then:
trtexec --onnx=model.onnx --saveEngine=model.engine --fp16
@timarnoldev The ONNX model exported using yolo export
does not include the EfficientNMS plugin and cannot be used for inference with this project. If you need to export an ONNX model with the EfficientNMS plugin, you can install the trtyolo
CLI using pip install tensorrt_yolo
and follow the instructions in model_export.md for model export. If you want to achieve the same inference speed in Python as in C++, you should refer to the installing-tensorrt_yolo guide to build version 4.0 of tensorrt_yolo
.
I followed the steps from #28 exactly, but I it still crashes.
error: execv(/home/tk/TensorRT-YOLO/demo/detect/build/linux/x86_64/release/detect -e model.engine -i images -o output -l labels.txt) failed(-1)
This is the only output I get from the demo/detect/detect.cpp executable. Is there anything I can provide to you to troubleshoot the issue? @laugh12321
Steps to reproduce:
yolo task=detect mode=train epochs=200 batch=32 plots=True model=yolov10s.pt data=data.yaml
yolo export model=best.pt format=onnx opset=13 simplify max_det=100 conf=0.17 iou=0.65 nms
trtexec --onnx=best.onnx --saveEngine=models/model.engine --fp16
xmake run -P . detect -e models/model.engine -i images -o output -l labels.txt --cudaGraph
@timarnoldev Your process seems correct. Please confirm the following:
num_dets
, det_boxes
, det_scores
, and det_classes
, as shown in the example?demo/detect
, did you follow the steps in the deploy-build guide to compile the deploy
module?The image below shows an example of inference using demo/detect
after converting the yolov10s model to an engine
file, following your provided steps.
I can confirm that the outputs shown in Netron seems odd, but I have no clue why.
Do I have to have the environment activated, when I run the deploy commands?
I also just did the export again confirming I use your custom version of the yolov10 repo, but the output in Netron looks still the same.
@timarnoldev I suspect you are using the yolo
CLI from the THU-MIG yolov10 repository instead of the yolo
CLI from the laugh12321 yolov10 repository (nms branch).
Please follow these steps:
git clone -b nms https://github.com/laugh12321/yolov10.git
cd yolov10
conda create -n yolov10 python=3.9
conda activate yolov10
pip install -r requirements.txt
pip install -e .
yolo export model=best.pt format=onnx opset=13 simplify max_det=100 conf=0.17 iou=0.65 nms
Indeed that was the problem. I guess I first installed the yolo cli from the repo and then switched the branch. Thank you very much.
I have a simple demo which should use this library for inference. But it always crashes with a segmentation fault.
I tried it with yolov9 and yolov10. But everytime I get the same error
Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
Used versions:
NVIDIA-SMI 555.42.06 Driver Version: 555.42.06 CUDA Version: 12.5 TensorRT 10.2