Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

训练实例分割时发现一下错误(InvalidArgument) Broadcast dimension mismatch #19

Open
Du-J opened this issue May 28, 2023 · 7 comments

Comments

@Du-J
Copy link

Du-J commented May 28, 2023

您好,我在训练实例分割时发现一下错误,排查数据正常用pytorch版训练也正常,麻烦您帮忙看一下问题是否有解决办法,谢谢。
Traceback (most recent call last):
File "segment/train.py", line 663, in
main(opt)
File "segment/train.py", line 554, in main
train(opt.hyp, opt, device, callbacks)
File "segment/train.py", line 309, in train
loss, loss_items = compute_loss(pred, targets, masks=masks.astype("float32"))
File "/home/qwe/FRN/yolov5-Paddle-main/utils/segment/loss.py", line 47, in call
tcls, tbox, indices, anchors, tidxs, xywhn = self.build_targets(p, targets) # targets
File "/home/qwe/FRN/yolov5-Paddle-main/utils/segment/loss.py", line 159, in build_targets
gxi = gain[[2, 4]] - gxy # inverse
File "/home/qwe/.local/lib/python3.8/site-packages/paddle/fluid/dygraph/math_op_patch.py", line 304, in impl
return math_op(self, other_var, -1)
ValueError: (InvalidArgument) Broadcast dimension mismatch. Operands could not be broadcast together with the shape of X = [2] and the shape of Y = [0, 2, 8]. Received [2] in X is not equal to [8] in Y at i:2.
[Hint: Expected x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1 == true, but received x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1:0 != true:1.] (at /paddle/paddle/phi/kernels/funcs/common_shape.h:84)

@GuoQuanhao
Copy link
Owner

能提供一部分数据集样例吗,你使用的什么paddle版本

@frn888
Copy link

frn888 commented Jun 6, 2023

paddle是2.3.2 CUDA11.2 CUDNN是8.5 使用--resume报以下错误Traceback (most recent call last): File "segment/train.py", line 664, in main(opt) File "segment/train.py", line 555, in main train(opt.hyp, opt, device, callbacks) File "segment/train.py", line 310, in train loss, loss_items = compute_loss(pred, targets, masks=masks.astype("float32")) File "/home/cathay/FRN/yolov5-Paddle/utils/segment/loss.py", line 84, in call for bi in b.unique(): File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/tensor/manipulation.py", line 1229, in unique return_counts, 'axis', axis, "is_sorted", True) SystemError: (Fatal) Operator unique raises an thrust::system::system_error exception. The exception content is :parallel_for failed: cudaErrorInvalidConfiguration: invalid configuration argument. (at /paddle/paddle/fluid/imperative/tracer.cc:307) terminate called without an active exception
训练开始时报以下错误
7ed91438699346e6d2b56b6cdca996b

@frn888
Copy link

frn888 commented Jun 8, 2023

Validating runs/train-seg/exp2/weights/best.pdparams...
Traceback (most recent call last):
File "segment/train.py", line 664, in
main(opt)
File "segment/train.py", line 555, in main
train(opt.hyp, opt, device, callbacks)
File "segment/train.py", line 429, in train
model=attempt_load(f, fp16=cuda, verbose=False),
File "/home/cathay/FRN/yolov5-Paddle/models/experimental.py", line 102, in attempt_load
anchors=ckpt_weights['hyp'].get('anchors') if hasattr(ckpt_weights, 'hyp') else None)
File "/home/cathay/FRN/yolov5-Paddle/models/yolo.py", line 199, in init
m.stride = paddle.to_tensor([s / x.shape[-2] for x in forward(paddle.zeros([1, ch, s, s], dtype=paddle.get_default_dtype()))]) # forward
File "/home/cathay/FRN/yolov5-Paddle/models/yolo.py", line 198, in
forward = lambda x: self.forward(x)[0] if isinstance(m, Segment) else self.forward(x)
File "/home/cathay/FRN/yolov5-Paddle/models/yolo.py", line 214, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "/home/cathay/FRN/yolov5-Paddle/models/yolo.py", line 123, in _forward_once
x = m(x) # run
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/fluid/dygraph/layers.py", line 930, in call
return self._dygraph_call_func(*inputs, **kwargs)
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/fluid/dygraph/layers.py", line 915, in _dygraph_call_func
outputs = self.forward(*inputs, **kwargs)
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/nn/layer/common.py", line 417, in forward
name=self.name)
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/nn/functional/common.py", line 475, in interpolate
out = _C_ops.nearest_interp_v2(x, *dy_attr)
RuntimeError: (NotFound) Operator nearest_interp_v2 does not have kernel for {data_type[::paddle::platform::float16]; data_layout[Undefined(AnyLayout)]; place[Place(gpu:0)]; library_type[PLAIN]}.
[Hint: Expected kernel_iter != kernels.end(), but received kernel_iter == kernels.end().] (at /paddle/paddle/fluid/imperative/prepared_operator.cc:419)
[operator < nearest_interp_v2 > error]

@frn888
Copy link

frn888 commented Jun 20, 2023

Traceback (most recent call last):
File "detect.py", line 255, in
main(opt)
File "detect.py", line 250, in main
run(**vars(opt))
File "", line 2, in run
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/fluid/dygraph/base.py", line 354, in _decorate_function
return func(*args, **kwargs)
File "detect.py", line 149, in run
det[:, :4] = scale_boxes(im.shape[2:], det[:, :4], im0.shape).round()
File "/home/cathay/.conda/envs/paddle/lib/python3.6/site-packages/paddle/fluid/dygraph/varbase_patch_methods.py", line 740, in getitem
return self._getitem_index_not_tensor(item)
ValueError: (InvalidArgument) Too many indices (2) for tensor of dimension 1.
[Hint: Expected valid_indexs <= rank == true, but received valid_indexs <= rank:0 != true:1.] (at /paddle/paddle/fluid/pybind/slice_utils.h:288)

@frn888
Copy link

frn888 commented Aug 2, 2023

您好 训练使用的动态度可以改成静态图训练吗?

@GuoQuanhao
Copy link
Owner

不能哦

@Du-J
Copy link
Author

Du-J commented Aug 8, 2023

导出的模型可以是静态图模型吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants