Onnx vs torch.export - Performance Gap
Reddit r/MLOps1w4 min read
I exported a fine-tuned U-Net model using both ONNX Runtime and torch.export with a fixed input shape of (64, 3, 512, 512). Here are the benchmark results for average inference time: ONNX Runtime: ~133.33 s torch.export: ~0.81 s I expected ONNX Runtime to perform on par with or faster than PyTorch export. What could be causing this ~160x slowdown? onnx_inputs = [torch.randn(64, 3, IMG_SIZE, IMG_SIZE).numpy(force=True)] ort_session = onnxruntime.InferenceSession( "./model.onnx", providers=["CUDAExecutionProvider"] ) onnxruntime_input = {input_arg.name: input_value for input_arg, input_value in
