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

I successfully exported model.pt to TensorRT, but why is the runtime usage of TensorRT slower than using .pt? #11478

Closed
1 task done
anhquyetnguyen opened this issue May 3, 2023 · 9 comments
Labels
question Further information is requested Stale

Comments

@anhquyetnguyen
Copy link

Search before asking

Question

I successfully exported model.pt to TensorRT, but why is the runtime usage of TensorRT slower than using .pt?

Additional

No response

@anhquyetnguyen anhquyetnguyen added the question Further information is requested label May 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2023

👋 Hello @anhquyetnguyen, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics

@glenn-jocher
Copy link
Member

@anhquyetnguyen hello,

We're glad to hear that you have successfully exported your model.pt to TensorRT using YOLOv5.

Regarding your question, TensorRT generally runs faster than PyTorch because it optimizes the neural network specifically for your GPU. However, it's possible that your TensorRT implementation may not be optimized or configured correctly.

We recommend that you check your TensorRT version, ensure that it's properly set up and configured with your GPU, and use TensorRT benchmarking tools to identify bottlenecks or performance issues.

Feel free to share more information or code snippets related to your use case, so that we can provide more specific help.

Best regards!

@anhquyetnguyen
Copy link
Author

anhquyetnguyen commented May 4, 2023

@glenn-jocher Thank you for your response
What version do you recommend? I have tried several versions of TensorRT, but they run slower when inferring from the PT file. Could you provide some information about the CUDA, cuDNN, TensorRT, and NVIDIA TensorRT versions? I am using your source code to train, export, and infer

@glenn-jocher
Copy link
Member

Hello @anhquyetnguyen,

Thanks for getting back to me. Since the performance of your TensorRT implementation is slower than using PT file, I recommend you to check your hardware drivers and make sure they are updated to the latest version.
Regarding the version of TensorRT, CUDA, cuDNN, and NVIDIA TensorRT, it depends on the configurations of your hardware and software. For further assistance, please provide more details of your computer hardware specifications, including GPU type, and software specifications such as the operating system, PyTorch version, CUDA version, and cuDNN version.

Looking forward to hearing back from you with more details!

@anhquyetnguyen
Copy link
Author

hi @glenn-jocher
ubuntu 18.04
Nvidia Tesla T4 16GB
cuda: 11.3
cudnn: 8.x
torch. 1.13.1

@glenn-jocher
Copy link
Member

Hello @anhquyetnguyen,
Thanks for providing the specifications of your hardware and software configurations. You seem to have an Nvidia Tesla T4 with 16GB memory, and CUDA 11.3, and cuDNN 8.x installed. However, you mentioned that YOLOv5's TensorRT implementation running slower than using PT file.
Since you're using PyTorch 1.3.1, I encourage you to update your PyTorch version to the latest version to ensure that your system is compatible with the latest TensorRT version.
Additionally, you may want to check the version compatibility table of TensorRT with CUDA and cuDNN on the Nvidia website to ensure that the versions you have installed are compatible with each other and your hardware.
I hope this helps, please let me know if you have any further questions!

@Shahji55
Copy link

Shahji55 commented May 10, 2023

Hi @glenn-jocher,
I'm encountering a similar issue. I trained a yolov5s model on a custom dataset and converted the .pt weight to TensorRT (fp16 precision) using the repo's export.py script. I used a custom Docker for running the export.py script and then used the same Docker to perform video inference on a Windows machine using both .pt and .engine weights.

OS: Windows 10 64-bit
Cuda: 11.1
Pytorch: 1.8.2
GPU: Nvidia GTX 1650 - 4 GB
TensorRT version: 7.2.3.4

While processing the video I get less FPS with the .engine weight as compared to the .pt weight.

However, when I use the same Docker to process the video on a Ubuntu (18.04 64 bit) machine with a Geforce RTX 2080Ti - 11GB GPU, I get more FPS with the .engine weight as compared to the .pt weight.

Do you have any insights as to why this might be? Thank you.

@glenn-jocher
Copy link
Member

Hello @Shahji55,

Thank you for your question. Based on your description, it appears that TensorRT performs slower than using .pt weights when processing video inferences on a Windows machine with Nvidia GTX 1650, while on a Ubuntu (18.04 64 bit) machine with a Geforce RTX 2080Ti, you observed the opposite behavior.

There could be many reasons for this behavior, such as the version of TensorRT and the driver used on the Windows machine might not be set up correctly, or the configuration of your Docker container may not be optimized for the Windows environment. To resolve this issue, we would recommend the following steps:

  • Check if TensorRT and the driver are installed correctly on your Windows machine and update them to the latest version if possible.
  • Ensure that the environment and configuration of your Docker container are optimized for your Windows machine, including the configuration of the Docker runtime with the Nvidia runtime for GPU acceleration.
  • To avoid CUDA version mismatch between different platforms, you may want to have the same environment, including TensorRT and CUDA version, on both machines.

Please give these steps a try and let us know if they help resolve the issue. Feel free to let us know if you have any further queries!

@github-actions
Copy link
Contributor

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐

@github-actions github-actions bot added the Stale label Jun 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

3 participants