(MMDet3d) During the training & using binary cross entropy loss, CUDA error: device-side assert triggered (Nuscene v1.0 + mmdet3d)

Author: Rangooo123Created May 3, 2023Updated Jan 24, 2026

training, epoch 1 [14000/20000], so it is very strange to me. I searched for available solutions, but their issues are about 'CUDA error: device-side assert triggered' happened at the very beginning.

The I attached my traceback below, and the problem is clear that the error happen when calculating the binary cross entropy loss (at the bottom). I guess it would be hold a value larger than 1 or a NAN happened. But why this raised at the middle of the training? And how can I fix this? I saw some other same questions in stackoverflow, but none of them hold a solution.

I am using the oringal NuScenev1.0 dataset, could there be a problem when I created the 'train.pkl' following the mmdetection guides?

Thanks for any reply!

My conda env is:

python=3.6
CUDA=10.2
GCC>=5.4
Python=3.6
Pytorch=1.8.1
Torchvision=0.9.1
MMCV-full=1.4.0
MMDetection=2.14.0
MMSegmentation=0.14.1
MMDet3d

,0,0], thread:[9,0,0] Assertion input val >= zero && input val <= one" failed.40/1836opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator): block:00,0], thread: [10,0,0] Assertion input val >= zero && input val <= one" failed.opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block: 00,0], thread:[11,0,0] Assertion "input val >= zero && input val <= one" failed./opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block:[00,0, thread:[12,0,0] ssertion input val >= zero && input val <= one failed.opt/conda/conda-bld/pytorch 1616554799289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block;[00,0l, thread:[13,0,0] Assertion input val >= zero && input val <= one" failed./opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block:;0,0,0], thread:[14,0,0] Assertion input val >= zero && input val <= one" failed./opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block;[00,0l, thread: 15,0,0 Assertion input val >= zero && input val <= one" failed.opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss.cu:102: operator(): block:0,0,l, thread:[16,0,0] Assertion "input val >= zero && input val <= one" failed.opt/conda/conda-bld/pytorch 1616554790289/work/aten/src/ATen/native/cuda/Loss,cu:102: operator(): block:[0,0,0], thread:[17,0,0] Assertion "input val >= zero && input val <= one" failed.Traceback (most recent call last):

File"tools/train.py",line 279,in <module>

main

File"tools/train.py",line 275,in mainmeta=meta)File"/home nfs/xxx/hang/mmdetection3d/mmdet3d/apis/train.py", line 191, in train model

meta=meta)

File "/home nfs/xxx/hang/mmdetection3d/mmdet3d/apis/train.py", line 159,in train detectorrunner.run(data loaders , cfe.workflow)

File "/home nfs/xxx/anaconda3/envs/bev-py36/lib/python3.6/site-packages/torch/nn/modules/module.py3

line 889,in call implresult= self.forward(*input,**kwargs)File "/home nfs/xxx/anaconda3/envs/bev-py36/lib/python3.6/site-packages/mmcv/runner/fp16 utils,py"

line 128,in new funcoutput = old func(*new args,**new kwargs)File "/home nfs/xxx/hang/mmdetection3d/mmdet3d/models/detectors/fastbev.py", line 294, in forwardreturn self.forward train(img,img metas,**kwargs)File "/home nfs/xxx/hang/mmdetection3d/mmdet3d/models/detectors/fastbev,py", line 312, in forward train

loss_det = self.bbox head.loss(*x, gt bboxes 3d, gt labels 3d, img metas)File "/home nfs/xxx/anaconda3/envs/bev-py36/lib/python3.6/site-packages/mmcv/runner/fp16 utils,py"

line 214,in new funcoutput = old func(*new args,**new kwargs)File "/home nfs/xxx/hang/mmdetection3d/mdet3d/models/dense heads/free anchor3d head.py",line 234,in loss

positive losses.append(self.positive bag loss(matched cls prob, matched box prob))File "/home nfs/xxx/hang/mmdetection3d/mmdet3d/models/dense heads/free anchor3d head,py", line 272,in positive bag loss

bag prob,torch.ones like(bag prob),reduction='none')File "/home nfs/xxx/anaconda3/envs/bev-py36/lib/python3.6/site-packages/torch/nn/functional.py",line 2762,in binary cross entropy

return torch.C.nn.binary cross entropy(input, target, weight, reduction enum)RuntimeError: CUDA error: device-side assert triggeredAborted (core dumped)

================================================================================= I hope the training continue. I was about to try the solutions from https://discuss.pytorch.org/t/device-side-assert-triggered-when-using-binary-cross-entropy-loss/18214/18, but I don't know how to modify the loss function in MMDet3d files.

Source: open-mmlab/mmdetection3d