MichaelFan01 / STDC-Seg

Source Code of our CVPR2021 paper "Rethinking BiSeNet For Real-time Semantic Segmentation"
MIT License
709 stars 132 forks source link

TensorRT network must have at least one output and validation failed #65

Open DuyguSerbes opened 3 years ago

DuyguSerbes commented 3 years ago

When I try to run run_latency_stages.py below error occurs. Could you please help me?

...... %657 : Float(1, 19, 64, 128) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[1, 1], pads=[0, 0, 0, 0], strides=[1, 1]](%656, %conv_out.conv_out.weight), scope: BiSeNet/BiSeNetOutput[conv_out]/Conv2d[conv_out] # /home/duygu/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py:340:0 %658 : Tensor = onnx::Constant[value= 1 1 8 8 [ Variable[CPUFloatType]{4} ]](), scope: BiSeNet %output : Float(1, 19, 512, 1024) = onnx::Upsample[mode="nearest"](%657, %658), scope: BiSeNet # /home/duygu/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py:2485:0 return (%output)

ONNX [TensorRT] ERROR: Network must have at least one output [TensorRT] ERROR: Network validation failed. Traceback (most recent call last): File "run_latency_stages.py", line 99, in main() File "run_latency_stages.py", line 85, in main latency = compute_latency(model, inputDimension) File "/media/duygu/3a331d5c-a3b3-468b-b8f7-06df52fefee6/ocakirog/CV/STDC-Seg-master/latency/utils/darts_utils.py", line 174, in compute_latency_ms_tensorrt with build_engine("model.onnx") as engine: AttributeError: enter

ElBoudah commented 3 years ago

I had the same issue. I managed to fix this thanks to this comment.

Mobu59 commented 2 years ago

When I try to run run_latency_stages.py below error occurs. Could you please help me?

...... %657 : Float(1, 19, 64, 128) = onnx::Conv[dilations=[1, 1], group=1, kernel_shape=[1, 1], pads=[0, 0, 0, 0], strides=[1, 1]](%656, %conv_out.conv_out.weight), scope: BiSeNet/BiSeNetOutput[conv_out]/Conv2d[conv_out] # /home/duygu/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/modules/conv.py:340:0 %658 : Tensor = onnx::Constantvalue= 1 1 8 8 [ Variable[CPUFloatType]{4} ], scope: BiSeNet %output : Float(1, 19, 512, 1024) = onnx::Upsample[mode="nearest"](%657, %658), scope: BiSeNet # /home/duygu/anaconda3/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py:2485:0 return (%output)

ONNX [TensorRT] ERROR: Network must have at least one output [TensorRT] ERROR: Network validation failed. Traceback (most recent call last): File "run_latency_stages.py", line 99, in main() File "run_latency_stages.py", line 85, in main latency = compute_latency(model, inputDimension) File "/media/duygu/3a331d5c-a3b3-468b-b8f7-06df52fefee6/ocakirog/CV/STDC-Seg-master/latency/utils/darts_utils.py", line 174, in compute_latency_ms_tensorrt with build_engine("model.onnx") as engine: AttributeError: enter

hi, have you solved your problem?if so, could you please help me, cause I meet the same problem with you

amokame commented 2 years ago

I had the same issue. I managed to fix this thanks to this comment.

Sorry to bother you. I tried to change the build_engine in latency/utils/darts_utils.py as the following.

def build_engine(model_file):
    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:

I am not sure if I'm doing it right. It seems not working. Could you give me some suggestion? Thank you.