IDEA-Research / DN-DETR

[CVPR 2022 Oral] Official implementation of DN-DETR
Apache License 2.0
541 stars 62 forks source link

RuntimeError: "ms_deform_attn_forward_cuda" not implemented for 'Half' #26

Open leayz-888 opened 2 years ago

leayz-888 commented 2 years ago

When I try to use mixed precision training, the program reports an error: Traceback (most recent call last): File "main.py", line 414, in main(args) File "main.py", line 335, in main args.clip_max_norm, wo_class_error=wo_class_error, lr_scheduler=lr_scheduler, args=args, logger=(logger if args.save_log else None)) File "/home/lyz/DN-DETR/engine.py", line 48, in train_one_epoch outputs, mask_dict = model(samples, dn_args=(targets, args.scalar, args.label_noise_scale, args.box_noise_scale, args.num_patterns)) File "/home/lyz/anaconda3/envs/pytorch-1.8.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, kwargs) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/dab_deformable_detr.py", line 225, in forward hs, init_reference, inter_references, enc_outputs_class, enc_outputs_coord_unact = self.transformer(srcs, masks, pos, query_embeds, attn_mask) File "/home/lyz/anaconda3/envs/pytorch-1.8.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/deformable_transformer.py", line 173, in forward memory = self.encoder(src_flatten, spatial_shapes, level_start_index, valid_ratios, lvl_pos_embed_flatten, mask_flatten) File "/home/lyz/anaconda3/envs/pytorch-1.8.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, kwargs) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/deformable_transformer.py", line 281, in forward output = layer(output, pos, reference_points, spatial_shapes, level_start_index, padding_mask) File "/home/lyz/anaconda3/envs/pytorch-1.8.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, *kwargs) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/deformable_transformer.py", line 232, in forward src2 = self.self_attn(self.with_pos_embed(src, pos), reference_points, src, spatial_shapes, level_start_index, padding_mask) File "/home/lyz/anaconda3/envs/pytorch-1.8.1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(input, **kwargs) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/ops/modules/ms_deform_attn.py", line 113, in forward value, input_spatial_shapes, input_level_start_index, sampling_locations, attention_weights, self.im2col_step) File "/home/lyz/DN-DETR/models/dn_dab_deformable_detr/ops/functions/ms_deform_attn_func.py", line 26, in forward value, value_spatial_shapes, value_level_start_index, sampling_locations, attention_weights, ctx.im2col_step) RuntimeError: "ms_deform_attn_forward_cuda" not implemented for 'Half' may I ask why?

FengLi-ust commented 2 years ago

Hey, because deformable attention does not support half precision. You can refer to deformable detr for more details.