i produced pth model and then onnx with dynnamic axes
but when i want to build an trt engine from it
i get :
[TensorRT] ERROR: Parameter check failed at: ../builder/Network.cpp::addInput::671, condition: isValidDims(dims, hasImplicitBatchDimension())
is_success False
In node -1 (importInput): UNSUPPORTED_NODE: Assertion failed: *tensor = importer_ctx->network()->addInput( input.name().c_str(), trt_dtype, trt_dims)
[TensorRT] ERROR: Network must have at least one output
Environment
TensorRT Version: 6.0.5.8 GPU Type:1050 Ti Nvidia Driver Version: CUDA Version: 10.2 CUDNN Version: 7.6.5 Operating System + Version: ubuntu 18 Python Version (if applicable): 3.6 TensorFlow Version (if applicable): no PyTorch Version (if applicable): 1.6 (1.2 tested too) Baremetal or Container (if container which image + tag): no
Relevant Files
get craft model from craft_pytorch repo in github
Please attach or include links to any models, data, files, or scripts necessary to reproduce your issue. (Github repo, Google Drive, Dropbox, etc.)
Steps To Reproduce
part of export to onnx :
input_batch = 1
input_channel = 3
input_h = 448
input_w = 448
output_batch = input_batch
output_h = input_h / 2
output_w = input_w / 2
inputc = torch.randn(input_batch, input_channel, \
input_h, input_w, device='cuda')
outputc = net(inputc.cuda())
output_names = ["output1","output2"]
input_names = ["inputc"]
dynamic_axes = {'inputc': { 2: "inputc_h", 3: 'inputc_w'},'output1': { 2: "output1_h", 3: 'output1_w'} , 'output2': { 2: "output2_h", 3: 'output2_w'}}
torch.onnx.export(
net,
inputc,
'craft5.onnx',
export_params=True, # store the trained parameter weights inside the model file
opset_version=10, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
#opset_version=11,
verbose=True,
input_names=['inputc'],
output_names=['output1','output2'],
dynamic_axes=dynamic_axes,)
def build_engine_onnx(model_file):
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.OnnxParser(network, TRT_LOGGER) as parser:
builder.max_workspace_size = 1 << 30
# Load the Onnx model and parse it in order to populate the TensorRT network.
with open(model_file, 'rb') as model:
is_success = parser.parse(model.read())
print('is_success',is_success)
if not is_success:
for error in range(parser.num_errors):
print(parser.get_error(error))
return builder.build_cuda_engine(network)
solutions that not worked
expilict batch is set to1 and network but dosn’t worked
change pytorch version from 1.6 to 1.2
i don’t think that updating to tensorrt7 would work
Hi,
Request you to share the ONNX model and the script if not shared already so that we can assist you better.
Alongside you can try few things:
validating your model with the below snippet
check_model.py
import sys
import onnx
filename = yourONNXmodel
model = onnx.load(filename)
onnx.checker.check_model(model).
2) Try running your model with trtexec command. https://github.com/NVIDIA/TensorRT/tree/master/samples/opensource/trtexec
In case you are still facing issue, request you to share the trtexec “”–verbose"" log for further debugging
Thanks!
Looks like you’re using very old version of TensorRT. We request you to please try on latest TensorRT version 8.0.
Please let us know if you still face this issue. We recommend you to please share ONNX model and script/steps to reproduce the issue.