facebookresearch / maskrcnn-benchmark

Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.
MIT License
9.29k stars 2.5k forks source link

RuntimeError: empty is not implemented for type CUDABoolType What is the problem? #1148

Open czh-hk opened 4 years ago

czh-hk commented 4 years ago

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. I want to train the model with my own data set in vac_cocostyle format.
  2. I find my .json file has same structure with the official one.
  3. I have modified the /maskrcnn_benchmark/config/defaults.py, and the datasets name and class_num is right.
  4. I use this config to run python tools/train_net.py --config-file "configs/e2e_mask_rcnn_R_50_FPN_1x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1 MODEL.RPN.FPN_POST_NMS_TOP_N_TRAIN 2000 and I have even modified the train and test datasets name in this .yaml file.

Error

2019-10-25 21:49:20,365 maskrcnn_benchmark.utils.miscellaneous WARNING: Dataset [ConcatDataset] has no categories attribute, labels.json file won't be created 2019-10-25 21:49:20,382 maskrcnn_benchmark.trainer INFO: Start training Traceback (most recent call last): File "tools/train_net.py", line 201, in main() File "tools/train_net.py", line 194, in main model = train(cfg, args.local_rank, args.distributed) File "tools/train_net.py", line 94, in train arguments, File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/engine/trainer.py", line 88, in do_train loss_dict = model(images, targets) File "/userhome/34/h3558561/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(input, kwargs) File "/userhome/34/h3558561/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/apex-0.1-py3.7-linux-x86_64.egg/apex/amp/_initialize.py", line 197, in new_fwd applier(kwargs, input_caster)) File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py", line 50, in forward proposals, proposal_losses = self.rpn(images, features, targets) File "/userhome/34/h3558561/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(input, *kwargs) File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/rpn.py", line 159, in forward return self._forward_train(anchors, objectness, rpn_box_regression, targets) File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/rpn.py", line 175, in _forward_train anchors, objectness, rpn_box_regression, targets File "/userhome/34/h3558561/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(input, **kwargs) File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/inference.py", line 146, in forward boxlists = self.select_over_all_levels(boxlists) File "/userhome/34/h3558561/maskrcnn-benchmark/maskrcnn_benchmark/modeling/rpn/inference.py", line 174, in select_over_all_levels inds_mask = torch.zeros_like(objectness, dtype=torch.bool) RuntimeError: empty is not implemented for type CUDABoolType

Only I have this problem?

shehabk commented 4 years ago

I had the same issue. Until the issue is resolved you can work with a little older version of code, I am working with this.

jasonRichter commented 4 years ago

I am experiencing this same issue.

florazxf commented 4 years ago

I am experiencing this same issue.

Muyun99 commented 4 years ago

I am experiencing this same issue.Hope someone to fix it.

attashe commented 4 years ago

I've replaced torch.bool to torch.uint8. It's work

AllenYuQ commented 4 years ago

I've replaced torch.bool to torch.uint8. It's work

it doesn't work in my situation.

AllenYuQ commented 4 years ago

I am experiencing this same issue.

Hey, bro, have u sloved this problem?

Liang-ZX commented 4 years ago

I am experiencing this same issue.

Hey, bro, have u sloved this problem?

Replacing torch.bool to torch.uint8 in three places can make it work.

AllenYuQ commented 4 years ago

Actually, there are three places required to be modified listed as follows: maskrcnn_benchmark/structures/segmentation_mask.py maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py maskrcnn-benchmark-master/maskrcnn_benchmark/modeling/rpn/inference.py subscribe torch.bool with torch.uint8 And the most import thing is that you need to remove the build files and execute ‘python setup.py build_ext install‘ again.