HikariTJU / LD

Localization Distillation for Object Detection (CVPR 2022, TPAMI 2023)
Apache License 2.0
355 stars 51 forks source link

将DKD与LD结合的问题 #67

Closed 1014llj closed 8 months ago

1014llj commented 1 year ago

您好,在阅读完LD后,我已成功复现ld_r50_gflv1_r101_fpn_coco_1x.py,看到你们的知乎解析上有说LD + DKD的结合可能会有更好的效果,便尝试去将DKD结合到LD中,我在kd_loss.py这个文件中模仿原有的kd_loss新加入了dkd_loss,由于dkd需要labels去区分目标类和非目标类来计算损失,我在ld_head.py文件的242行后和269行后分别加入了labels[pos_inds]和labels[remain_inds],将labels的值传入kd_loss.py,并添加了一个新的wrapper与之适配,其他位置均未改动,之后我将ld_r50_gflv1_r101_fpn_coco_1x.py 文件的第43行loss_kd的type改为新定义的dkd训练coco数据集,出现了以下错误

/opt/conda/conda-bld/pytorch_1659484810403/work/aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block:[3,0,0], thread:[1,0,0] Assertion 'idx_dim >= 0 && idx_dim < index_size && "index out of bounds"' failed.
/opt/conda/conda-bld/pytorch_1659484810403/work/aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block:[3,0,0], thread:[2,0,0] Assertion 'idx_dim >= 0 && idx_dim < index_size && "index out of bounds"' failed.
...
/opt/conda/conda-bld/pytorch_1659484810403/work/aten/src/ATen/native/cuda/ScatterGatherKernel.cu:365: operator(): block:[3,0,0], thread:[31,0,0] Assertion 'idx_dim >= 0 && idx_dim < index_size && "index out of bounds"' failed.
terminate called after throwing an instance of 'c10::CUDAError'
CUDA error: device -side assert triggered

这个错误没有报出错的的位置,去查过可能是数组越界,但是无法定位到具体出错的位置,想请问下您有什么解决的建议吗?

HikariTJU commented 1 year ago

你能定位到是哪个数组越界了吗

1014llj commented 1 year ago

您好,非常感谢您的回答,我不知道该如何定位数组越界问题,想请问您有什么好的方法,这是我的错误日志文件20230515_203930.log,它没有报具体的错误位置,我不好定位,同时也想请问您觉得可能出错的位置有哪些?非常感谢

HikariTJU commented 1 year ago

你会用VS code的debug吗,它会在出错的地方停下来

1014llj commented 1 year ago

好的,非常感谢,我去试一下VS code

1014llj commented 1 year ago

你好,我自己试了下VS code,之前没有debug过这种模型训练的文件,不太清楚该如何debug,想请教您一下该如何使用VS code去debug,非常感谢。

HikariTJU commented 1 year ago

https://code.visualstudio.com/docs/python/debugging

1014llj commented 1 year ago

好的,非常感谢您。

yjq404 commented 1 year ago

@1014llj 同学你好,可以要一个你的联系方式吗?想交流一下蒸馏在检测中的应用