mit-han-lab / efficientvit

EfficientViT is a new family of vision models for efficient high-resolution vision.
Apache License 2.0
1.6k stars 142 forks source link

how can we deploy E-Vit Sam in other platform #63

Open SoulProficiency opened 4 months ago

SoulProficiency commented 4 months ago

how can we deploy E-Vit Sam in other platform?such rockchip platform(RK) or ascend platform(HUAWEI platform)?

SoulProficiency commented 4 months ago

how can we export l0(pt) to onnx?something wrong when i follow the sam.md to export onnx,here is the error when onnx2trt:

02/18/2024-09:15:57] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:364: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[02/18/2024-09:15:57] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[02/18/2024-09:15:57] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[02/18/2024-09:15:57] [E] Error[4]: [shuffleNode.cpp::symbolicExecute::387] Error Code 4: Internal Error (/image_encoder/backbone/stages.4/op_list.1/context_module/main/Reshape_1: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
[02/18/2024-09:15:57] [E] [TRT] parsers/onnx/ModelImporter.cpp:780: While parsing node number 325 [Pad -> "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad_output_0"]:
[02/18/2024-09:15:57] [E] [TRT] parsers/onnx/ModelImporter.cpp:781: --- Begin node ---
[02/18/2024-09:15:57] [E] [TRT] parsers/onnx/ModelImporter.cpp:782: input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Slice_2_output_0"
input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Cast_output_0"
input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Constant_25_output_0"
output: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad_output_0"
name: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad"
op_type: "Pad"
attribute {
  name: "mode"
  s: "constant"
  type: STRING
}

[02/18/2024-09:15:57] [E] [TRT] parsers/onnx/ModelImporter.cpp:783: --- End node ---
[02/18/2024-09:15:57] [E] [TRT] parsers/onnx/ModelImporter.cpp:785: ERROR: parsers/onnx/ModelImporter.cpp:179 In function parseGraph:
[6] Invalid Node - /image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad
[shuffleNode.cpp::symbolicExecute::387] Error Code 4: Internal Error (/image_encoder/backbone/stages.4/op_list.1/context_module/main/Reshape_1: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
[02/18/2024-09:15:57] [E] Failed to parse onnx file
[02/18/2024-09:15:57] [I] Finish parsing network model
[02/18/2024-09:15:57] [E] Parsing model failed
[02/18/2024-09:15:57] [E] Failed to create engine from model.
[02/18/2024-09:15:57] [E] Engine set up failed
&&&& FAILED TensorRT.trtexec [TensorRT v8203] # trtexec --onnx=./l0_encoder.onnx --minShapes=input_image:1x3x512x512 --optShapes=input_image:4x3x512x512 --maxShapes=input_image:4x3x512x512 --saveEngine=./l0__encoder.engine --fp16
SoulProficiency commented 4 months ago

same to xl1,tensorrt8.2

[libprotobuf WARNING /home/jenkins/agent/workspace/OSS/OSS_L0_MergeRequest/oss/build/third_party.protobuf/src/third_party.protobuf/src/google/protobuf/io/coded_stream.cc:81] The total number of bytes read was 797487046
[02/18/2024-09:27:14] [I] [TRT] ----------------------------------------------------------------
[02/18/2024-09:27:14] [I] [TRT] Input filename:   xl1_encoder.onnx
[02/18/2024-09:27:14] [I] [TRT] ONNX IR version:  0.0.7
[02/18/2024-09:27:14] [I] [TRT] Opset version:    12
[02/18/2024-09:27:14] [I] [TRT] Producer name:    pytorch
[02/18/2024-09:27:14] [I] [TRT] Producer version: 2.0.0
[02/18/2024-09:27:14] [I] [TRT] Domain:           
[02/18/2024-09:27:14] [I] [TRT] Model version:    0
[02/18/2024-09:27:14] [I] [TRT] Doc string:       
[02/18/2024-09:27:14] [I] [TRT] ----------------------------------------------------------------
[libprotobuf WARNING /home/jenkins/agent/workspace/OSS/OSS_L0_MergeRequest/oss/build/third_party.protobuf/src/third_party.protobuf/src/google/protobuf/io/coded_stream.cc:604] Reading dangerously large protocol message.  If the message turns out to be larger than 2147483647 bytes, parsing will be halted for security reasons.  To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
[libprotobuf WARNING /home/jenkins/agent/workspace/OSS/OSS_L0_MergeRequest/oss/build/third_party.protobuf/src/third_party.protobuf/src/google/protobuf/io/coded_stream.cc:81] The total number of bytes read was 797487046
[02/18/2024-09:27:15] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:364: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[02/18/2024-09:27:15] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[02/18/2024-09:27:15] [W] [TRT] parsers/onnx/onnx2trt_utils.cpp:392: One or more weights outside the range of INT32 was clamped
[02/18/2024-09:27:15] [E] Error[4]: [shuffleNode.cpp::symbolicExecute::387] Error Code 4: Internal Error (/image_encoder/backbone/stages.4/op_list.1/context_module/main/Reshape_1: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
[02/18/2024-09:27:15] [E] [TRT] parsers/onnx/ModelImporter.cpp:780: While parsing node number 287 [Pad -> "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad_output_0"]:
[02/18/2024-09:27:15] [E] [TRT] parsers/onnx/ModelImporter.cpp:781: --- Begin node ---
[02/18/2024-09:27:15] [E] [TRT] parsers/onnx/ModelImporter.cpp:782: input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Slice_2_output_0"
input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Cast_output_0"
input: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Constant_25_output_0"
output: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad_output_0"
name: "/image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad"
op_type: "Pad"
attribute {
  name: "mode"
  s: "constant"
  type: STRING
}

[02/18/2024-09:27:15] [E] [TRT] parsers/onnx/ModelImporter.cpp:783: --- End node ---
[02/18/2024-09:27:15] [E] [TRT] parsers/onnx/ModelImporter.cpp:785: ERROR: parsers/onnx/ModelImporter.cpp:179 In function parseGraph:
[6] Invalid Node - /image_encoder/backbone/stages.4/op_list.1/context_module/main/Pad
[shuffleNode.cpp::symbolicExecute::387] Error Code 4: Internal Error (/image_encoder/backbone/stages.4/op_list.1/context_module/main/Reshape_1: IShuffleLayer applied to shape tensor must have 0 or 1 reshape dimensions: dimensions were [-1,2])
[02/18/2024-09:27:15] [E] Failed to parse onnx file
[02/18/2024-09:27:16] [I] Finish parsing network model
[02/18/2024-09:27:16] [E] Parsing model failed
[02/18/2024-09:27:16] [E] Failed to create engine from model.
[02/18/2024-09:27:16] [E] Engine set up failed
&&&& FAILED TensorRT.trtexec [TensorRT v8203] # trtexec --onnx=xl1_encoder.onnx --minShapes=input_image:1x3x1024x1024 --optShapes=input_image:4x3x1024x1024 --maxShapes=input_image:4x3x1024x1024 --saveEngine=xl1_encoder.engine
zhuoyang20 commented 4 months ago

Hi SoulProficiency,

We recommend you to use the latest TensorRT version 8.6.

Best, Zhuoyang