LiheYoung / UniMatch

[CVPR 2023] Revisiting Weak-to-Strong Consistency in Semi-Supervised Semantic Segmentation
https://arxiv.org/abs/2208.09910
MIT License
476 stars 59 forks source link

关于您该项目的实验 #99

Closed Secret813 closed 11 months ago

Secret813 commented 1 year ago

您好,我想对您的项目做一些实验,增加了一个模块用到了 `def label_onehot(inputs, num_segments): batch_size, im_h, im_w = inputs.shape

remap invalid pixels (-1) into 0, otherwise we cannot create one-hot vector with negative labels.

# we will still mask out those invalid values in valid mask
inputs = torch.relu(inputs)
outputs = torch.zeros([batch_size, num_segments, im_h, im_w]).to(inputs.device)
return outputs.scatter_(1, inputs.unsqueeze(1), 1.0)`

这一函数。运行的时候报错RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1. 定位后报错出现在了上面这段函数。具体为: File "unimatch.py", line 288, in <module> main() File "unimatch.py", line 209, in main mask_l = F.interpolate(label_onehot(mask_x, 19),size=preds.shape[2:], mode='nearest') File "/root/UniMatch2/supervised.py", line 95, in label_onehot return outputs.scatter_(1, inputs.unsqueeze(1), 1.0) RuntimeError: CUDA error: device-side assert triggered请问您知道如何解决嘛?

Secret813 commented 1 year ago

[2023-11-27 18:16:25,627][ INFO] ===========> Epoch: 0, LR: 0.00500, Previous best: 0.00 ../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block: [1104,0,0], thread: [64,0,0] Assertion idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failed. ../aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block: [1104,0,0], thread: [65,0,0] Assertion idx_dim >= 0 && idx_dim < index_size && "index out of bounds" failed.

LiheYoung commented 1 year ago

这应该是你希望scatter的类别的index大于了你one-hot规定的最大的类别(最大类别index似乎是18?(19-1)),可以检查一下你的inputs这个变量

Secret813 commented 1 year ago

非常感谢!