无法将 ONNX 模型解析为 TensorRT
Failed to parse ONNX model to TensorRT
我正在使用 jetson nano
我尝试转换onnx模型https://github.com/onnx/models/tree/master/vision/body_analysis/emotion_ferplus
运行 进入这个错误:
https://user-images.githubusercontent.com/28679735/86281506-a75e5380-bbab-11ea-8608-9bf8e2f50cc6.png
附加信息:
https://user-images.githubusercontent.com/28679735/86281617-d674c500-bbab-11ea-8bbe-16f6d3db7203.png
创建模型后使用此代码:
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:
with open("modelfile.onnx", 'rb') as model:
if not parser.parse(model.read()):
for error in range(parser.num_errors):
print(parser.get_error(error))
engine = builder.build_cuda_engine(network)
您可以直接使用引擎,也可以保存以后再使用。
with open("output.engine", "wb") as f:
f.write(engine.serialize())
我正在使用 jetson nano
我尝试转换onnx模型https://github.com/onnx/models/tree/master/vision/body_analysis/emotion_ferplus
运行 进入这个错误:
https://user-images.githubusercontent.com/28679735/86281506-a75e5380-bbab-11ea-8608-9bf8e2f50cc6.png
附加信息:
https://user-images.githubusercontent.com/28679735/86281617-d674c500-bbab-11ea-8bbe-16f6d3db7203.png
创建模型后使用此代码:
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:
with open("modelfile.onnx", 'rb') as model:
if not parser.parse(model.read()):
for error in range(parser.num_errors):
print(parser.get_error(error))
engine = builder.build_cuda_engine(network)
您可以直接使用引擎,也可以保存以后再使用。
with open("output.engine", "wb") as f:
f.write(engine.serialize())