Provide details on the platforms you are using:
Ubuntu 18.04
Tesla V100
Driver 418.39
CUDA 10.0
CUDNN 7
Python version 3.6.7
Pytorch 1.0.1.post2
TensorRT 5.0.2.6
Describe the problem
Importing an ONNX model with an upsampling error raises the following error:
IndexError: Attribute not found: height_scale
I think the reason for this is that ONNX changed the behaviour of the upsampling operator in Operator Set 9 (see Change upsample operator to allow dynamic 'scales' by linkerzhang · Pull Request #1467 · onnx/onnx · GitHub).
Onnx-tensorrt have met the same problem and solved it here: https://github.com/onnx/onnx-tensorrt/pull/80
To reproduce the error, run the following code:
import torch
from torch import nn
import tensorrt as trt
class Model(nn.Module):
def forward(self, x):
return nn.functional.interpolate(x, scale_factor=2)
dummy_input = torch.rand(1, 3, 20, 20)
torch.onnx.export(Model(), dummy_input, 'test.onnx')
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
def GiB(val):
return val * 1 << 30
with trt.Builder(TRT_LOGGER) as builder, \
builder.create_network() as network, \
trt.OnnxParser(network, TRT_LOGGER) as parser:
builder.max_workspace_size = GiB(1)
# Load the Onnx model and parse it in order to populate the TensorRT network.
with open('test.onnx', 'rb') as model:
success = parser.parse(model.read())