Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.6k stars 510 forks source link

Cannot convert to tensorrt from exported onnx model #1254

Closed lpkoh closed 1 year ago

lpkoh commented 1 year ago

šŸ› Describe the bug

I am using

I have managed to train a model and successfully do conversion on a Lambda GPU labs instance with single A100 and single A6000 GPU.

However, on my own machine with Nvidia driver version 515.105.01, Cuda version 11.7, as well as on a AGX Xavier machine, in both cases I face the error: _[TensorRT] ERROR: 3: getPluginCreator could not find plugin: NonZero version: 1 convert_trt.py:13: DeprecationWarning: Use build_serialized_network instead. engine = builder.build_engine(network, config) [TensorRT] ERROR: 4: [network.cpp::validate::2411] Error Code 4: Internal Error (Network must have at least one output) Traceback (most recent call last): File "convert_trt.py", line 26, in save_engine(engine, engine_file_path) File "convert_trt.py", line 18, in saveengine f.write(engine.serialize()) AttributeError: 'NoneType' object has no attribute 'serialize'

This is even when I use your own code block instead of my own (so just a pretrained model:

# Load model with pretrained weights
from super_gradients.training import models
from super_gradients.common.object_names import Models

model = models.get(Models.YOLO_NAS_M, pretrained_weights="coco")

# Prepare model for conversion
# Input size is in format of [Batch x Channels x Width x Height] where 640 is the standard COCO dataset dimensions
model.eval()
model.prep_model_for_conversion(input_size=[1, 3, 640, 640])

# Create dummy_input

# Convert model to onnx
torch.onnx.export(model, dummy_input,  "yolo_nas_m.onnx")

And then: trtexec --fp16 --int8 --avgRuns=100 --onnx=model.onnx

Can anyone help suggest how to fix this?

Versions

Collecting environment information... PyTorch version: 1.11.0+cu113 Is debug build: False CUDA used to build PyTorch: 11.3 ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64) GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Clang version: Could not collect CMake version: version 3.26.4 Libc version: glibc-2.31

Python version: 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0] (64-bit runtime) Python platform: Linux-5.15.0-67-generic-x86_64-with-glibc2.29 Is CUDA available: True CUDA runtime version: 11.4.100 CUDA_MODULE_LOADING set to: GPU models and configuration: GPU 0: Tesla V100-DGXS-32GB GPU 1: Tesla V100-DGXS-32GB GPU 2: Tesla V100-DGXS-32GB GPU 3: Tesla V100-DGXS-32GB

Nvidia driver version: 515.105.01 cuDNN version: Probably one of the following: /usr/lib/x86_64-linux-gnu/libcudnn.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.2.2 /usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.2.2 HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 40 On-line CPU(s) list: 0-39 Thread(s) per core: 2 Core(s) per socket: 20 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 79 Model name: Intel(R) Xeon(R) CPU E5-2698 v4 @ 2.20GHz Stepping: 1 CPU MHz: 1200.000 CPU max MHz: 3600.0000 CPU min MHz: 1200.0000 BogoMIPS: 4397.43 Virtualization: VT-x L1d cache: 640 KiB L1i cache: 640 KiB L2 cache: 5 MiB L3 cache: 50 MiB NUMA node0 CPU(s): 0-39 Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Meltdown: Mitigation; PTI Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Vulnerability Retbleed: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear flush_l1d

Versions of relevant libraries: [pip3] numpy==1.23.0 [pip3] pytorch-quantization==2.1.2 [pip3] torch==1.11.0+cu113 [pip3] torchaudio==0.11.0+cu113 [pip3] torchmetrics==0.8.0 [pip3] torchvision==0.12.0+cu113 [pip3] triton==2.0.0 [conda] Could not collect

ChuRuaNh0 commented 1 year ago

https://github.com/Deci-AI/super-gradients/issues/1288

BloodAxe commented 1 year ago

We require TensorRT 8.4.1 See https://docs.deci.ai/super-gradients/documentation/source/BenchmarkingYoloNAS.html