TensorRT: `ValueError: vector::_M_default_append` when trying to parse distilbert from onnx
Hi, I’ve exported a Pytorch distilbert model to Onnx and am trying to load it using the Python API. My code looks like this:
logger.info(f"Exporting to onnx")
BATCH_SIZE=32
dummy_input = torch.randint(0, 10000, (BATCH_SIZE, 512))
torch.onnx.export(encoder, dummy_input, "encoder_complex.onnx", verbose=os.getenv("VERBOSE", False), opset_version=13)
# try simplification to see if it fixes anything
logger.info("Simplifying model")
onnx_model = onnx.load("encoder_complex.onnx")
onnx_simp_model, check = simplify(onnx_model)
assert check, f"Some error {check}"
onnx.save(onnx_simp_model, "encoder.onnx")
# Load onnx model into tensorrt engine and return that
logger.info("Creating TRT engine")
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
EXPLICIT_BATCH = 1 << (int)(trt.NetworkDefinitionCreationFlag.EXPLICIT_BATCH)
with trt.Builder(TRT_LOGGER) as builder, builder.create_network(EXPLICIT_BATCH) as network, trt.OnnxParser(network, TRT_LOGGER) as parser:
builder.max_workspace_size = common.GiB(1)
with open("encoder.onnx", 'rb') as model:
if not parser.parse(model.read()):
logger.error("Some problem parsing")
for error in range(parser.num_errors):
logger.error(parser.get_error(error))
return None
logger.info(f"Building engine with {network}")
return builder.build_cuda_engine(network)
Upon execution I see ValueError: vector::_M_default_append
on the parsing line if not parser.parse(model.read()):
and no other information.
Can someone please advise how to debug this and find the source of the error?
Environment:
GPU: RTX 3080
Driver: 460.67
OS: Ubuntu 20.04
Python: 3.7.10
Cuda: 11.2
Pytorch: 1.8.1+cu111
Cudnn: 8.1.1
TensorRT: 7.2.3.4
Onnx: 1.8.1
Thanks!
PS. I also looked at https://github.com/NVIDIA/TensorRT/issues/763 which reported the same issue, but that has been closed due to no response. I tried running this code in jupyter as well but don’t see any more details like that issue mentioned.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27
Hello @bdalal , all the fix will go into TRT 8.0 release, and also to OSS in June. Thanks!