先附上解决方案:参考修改config.h文件
[Convolution]:kernel weights has count 3840 but 32640 was expected,yolov5s生成engine模型失败_yolov5s.engine-CSDN博客https://blog.csdn.net/pvmsmfchcs/article/details/131388796修改这个config.h文件,然后继续修改
当前分割背景的类别不要算进去,训练的时候,是几个类别,这里就是几个,不要额外加一
遇见警告如下:
[04/10/2024-15:51:05] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
[04/10/2024-15:51:06] [W] [TRT] Weights [name=(Unnamed Layer* 346) [Deconvolution].weight] had the following issues when converted to FP16:
[04/10/2024-15:51:06] [W] [TRT] - Subnormal FP16 values detected.
[04/10/2024-15:51:06] [W] [TRT] If this is not the desired behavior, please modify the weights or retrain with regularization to reduce the magnitude of the weights.
onnx->trt F16:Subnormal FP16 value detected_if this is not the desired behavior, please modify-CSDN博客https://blog.csdn.net/Zhou_yongzhe/article/details/127289947成功之后的警告可以忽略不计。报错就不行了
一开始遇见报错如下:
Microsoft Windows [版本 10.0.19045.4170]
(c) Microsoft Corporation。保留所有权利。
D:\1>yolov8_seg -s yolov8s_seg.wts yolov8s_seg.engine s
Loading weights: yolov8s_seg.wts
[04/10/2024-15:27:05] [W] [TRT] The implicit batch dimension mode has been deprecated. Please create the network with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag whenever possible.
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
Building engine, please wait for a while...
[04/10/2024-15:27:05] [E] [TRT] 3: (Unnamed Layer* 247) [Convolution]:kernel weights has count 128 but 640 was expected
[04/10/2024-15:27:05] [E] [TRT] 4: (Unnamed Layer* 247) [Convolution]: count of 128 weights in kernel, but kernel dimensions (1,1) with 128 input channels, 5 output channels and 1 groups were specified. Expected Weights count is 128 * 1*1 * 5 / 1 = 640
[04/10/2024-15:27:05] [E] [TRT] 4: [convolutionNode.cpp::nvinfer1::builder::ConvolutionNode::computeOutputExtents::43] Error Code 4: Internal Error ((Unnamed Layer* 247) [Convolution]: number of kernel weights does not match tensor dimensions)
[04/10/2024-15:27:05] [E] [TRT] 4: [network.cpp::nvinfer1::Network::validate::2881] Error Code 4: Internal Error (Could not compute dimensions for (Unnamed Layer* 0) [Convolution]_output, because the network is not valid.)
[04/10/2024-15:27:05] [E] [TRT] 2: [builder.cpp::nvinfer1::builder::Builder::buildSerializedNetwork::636] Error Code 2: Internal Error (Assertion engine != nullptr failed. )
Build engine successfully!