Description
I want to convert a PyTorch model into a TensorRT model, but I have the impression that the device where I’m trying to perform the conversion doesn’t have enough memory, causing the conversion to fail. I would like to know if there is any way I can deal with this Python version (3.6.9) and this hardware architecture (NVIDIA Tegra X2, 3832MiB) to get the .engine (TensorRT) model and make it work properly.
The model has been trained on a dedicated machine (AWS EC2 g4dn.xlarge) using the YOLOv5 repository. The resulting .pt files from the command are attached below.
The export from PyTorch format (.pb) to TensorRT format (.engine) has been attempted on the TX2 NX device.
Throughout the export process, these errors and warnings appear:
[TensorRT] ERROR: Tactic Device request: 277MB Available: 264MB. Device memory is insufficient to use tactic.
[TensorRT] WARNING: Skipping tactic 3 due to oom error on requested size of 277 detected for tactic 5.
[TensorRT] ERROR: Tactic Device request: 356MB Available: 267MB. Device memory is insufficient to use tactic.
[TensorRT] WARNING: Skipping tactic 3 due to oom error on requested size of 356 detected for tactic 4.
Command used for model training (result: best.pt):
python train.py --data data/config_training.yaml --weights yolov5s.pt --img 640 --epochs 300 --device 0 --batch -1 --patience 15
Environment
TensorRT Version: 8.0.1.6
GPU Type: NVIDIA® Jetson™ TX2 NX - 4 Core ARM A57 Complex and 2 core NVIDIA Denver2 64-bit CPU - 4GB LPDDR4 - NVIDIA Tegra X2, 3832MiB
Nvidia Driver Version: nvidia-smi not installed
CUDA Version: cuda_10.2_r440.TC440_70.29663091_0
CUDNN Version:
Operating System + Version: Linux aaeon-desktop 4.9.253-tegra #1 SMP PREEMPT Mon Jul 26 12:19:28 PDT 2021 aarch64 GNU/Linux
Python Version: 3.6.9
PyTorch Version: 1.8.0
ONNX Version: 1.11.0
Baremetal or Container (if container which image + tag): yolov5==6.2.1
Relevant Files
For exportation to model.engine
For testing the model.engine
- load_tensorRT.py
- test folder → Neccesary to check the engine model performance
- mydata.yaml
Steps To Reproduce
- Generate a virtual environment with python 3.6.9
python3 -m venv ./newenvdeleteafter
source newenvdeleteafter/bin/activate
- Install YOLOv5 (you may be prompted to install additional libraries)
pip install yolov5==6.2.1
- Run the command for export ( I’ve also tried with sudo):
yolov5 export --weights best.pt --include [engine] --device 0 --imgsz [800,608] --data mydata.yaml --half --workspace 1
During exportation, log shows:
First warning:
WARNING: ⚠️ Python 3.7.0 is required by YOLOv5, but Python 3.6.9 is currently installed
Second warning:
[TensorRT] ERROR: Tactic Device request: 277MB Available: 264MB. Device memory is insufficient to use tactic.
[TensorRT] WARNING: Skipping tactic 3 due to oom error on requested size of 277 detected for tactic 5.
[TensorRT] ERROR: Tactic Device request: 356MB Available: 267MB. Device memory is insufficient to use tactic.
[TensorRT] WARNING: Skipping tactic 3 due to oom error on requested size of 356 detected for tactic 4.
- Loading the
model.engineand showing results
Concerns
On my PC with a larger amount of memory and Python v.3.10, the export process does not yield any warnings and works well. Because I can’t increase the memory of my TX2 NX, I would like to understand how relevant the warnings are and what would be the best way to avoid them. I believe upgrading to Python 3.7 is one option, but I would like to know if there are possibilities to make it work on 3.6.9
Below the result when i export the model on my PC.
I hope the question is clear. I apologize if the information is not accurate or is imprecise. I am not an expert in this matter and am learning as we develop this project. Thank you very much in advance.
I’ve also shared this information in the YOLOv5 GitHub repository

