NVIDIA / TensorRT

NVIDIA® TensorRT™ is an SDK for high-performance deep learning inference on NVIDIA GPUs. This repository contains the open source components of TensorRT.
https://developer.nvidia.com/tensorrt
Apache License 2.0
10.52k stars 2.1k forks source link

Convert a quantized conv-3d model failed #1726

Closed guxss3 closed 2 years ago

guxss3 commented 2 years ago

Description

I'm using PyTorch-Quantization Toolkit to create a QAT model, conv2d model works well, but when I using trtexec to convert a quantized conv3d model failed with the following error: Internal Error Snipaste_2022-01-13_16-44-21

I am not sure if trtexec support convert a QAT model with conv3d?

My simple 3D model: Snipaste_2022-01-13_16-44-34

Environment

TensorRT Version: 8.2.2 NVIDIA GPU: 2080ti NVIDIA Driver Version: 495.29.05 CUDA Version: 11.1 CUDNN Version: 8.0.5 Operating System: Windows 10 Python Version (if applicable): 3.6 Tensorflow Version (if applicable): PyTorch Version (if applicable): 1.8.1 Baremetal or Container (if so, version):

Relevant Files

onnx model: conv3d_int8.zip PyTorch-Quantization code: `import torch.nn as nn from pytorch_quantization import nn as quant_nn from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor from pytorch_quantization import quant_modules

class CONV3D_test(nn.Module): def init(self): super(CONV3D_test, self).init() self.enc_input = nn.Sequential( quant_nn.QuantConv3d(1, 18, kernel_size=3, padding=1, bias=False), nn.BatchNorm3d(18), nn.ReLU(), quant_nn.QuantConv3d(18, 18, kernel_size=3, padding=1, bias=False), nn.BatchNorm3d(18), nn.ReLU() ) def forward(self, x): enc_input = self.enc_input(x) return enc_input

quant_nn.TensorQuantizer.use_fb_fake_quant = True quant_modules.initialize() model =CONV3D_test().cuda() example = torch.rand(1, 1, 224, 224, 128).cuda() onnx_save_path = "D:/project/ct/3DDet/run/data_gjzy/resnet50_retinanet/conv3d_int8.onnx" torch.onnx.export(model, example, onnx_save_path, verbose=True, opset_version=13, training=torch.onnx.TrainingMode.EVAL, do_constant_folding=True, input_names=['input'], output_names=['output'], dynamic_axes=None)`

ttyio commented 2 years ago

@guxss3 , the error show that there is no mix precision (INT8-IN-FP32-OUT) 3d deconv kernel for your configuration, to fix the error, could you insert Q/DQ pair before the output? thanks!

ttyio commented 2 years ago

Closing since no activity for more than 3 weeks, please reopen if you still have issue, thanks!