title: Error with Detectron2 : RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same
body: <p>I'm getting this rather annoying error and I have no idea how to correct : RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same.</p>
  <p>I'm running the code for image detection locally on a Jupyter Notebook on a Cuda-enabled laptop (Ubuntu). The input is only 14 JPG images with a COCO format annotation file. Registration of the dataset doesn't seem to be the problem.</p>
  <pre><code>dataset_dicts = load_coco_json(&quot;../Downsampled/Train/annotations.json&quot;, &quot;../Downsampled/Train&quot;, dataset_name=&quot;Seals&quot;, extra_annotation_keys=None)
  register_coco_instances(&quot;seal&quot;, {}, &quot;../Downsampled/Train/annotations.json&quot;, &quot;../Downsampled/Train&quot;)
  
  cfg = get_cfg()
  cfg.merge_from_file(model_zoo.get_config_file(&quot;COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml&quot;))
  #cfg.merge_from_file(model_zoo.get_config_file(&quot;COCO-Detection/retinanet_R_50_FPN_3x.yaml&quot;))
  cfg.INPUT.MAX_SIZE_TRAIN = 2000
  cfg.INPUT.MIN_SIZE_TRAIN = 800
  cfg.INPUT.MAX_SIZE_TEST = 5000
  cfg.INPUT.MIN_SIZE_TEST = 1000
  cfg.DATASETS.TRAIN = (&quot;seal&quot;,)
  cfg.MODEL.PIXEL_MEAN = [mean_pixel_values[2], mean_pixel_values[1], mean_pixel_values[0]]
  cfg.MODEL.PIXEL_STD = [std_pixel_values[2], std_pixel_values[1], std_pixel_values[0]]
  cfg.DATASETS.TEST = ()  # no metrics implemented for this dataset
  #cfg.DATALOADER.NUM_WORKERS = 4
  cfg.MODEL.DEVICE=&quot;cuda&quot;
  cfg.MODEL.WEIGHTS = &quot;detectron2://ImageNetPretrained/MSRA/R-50.pkl&quot;  # initialize from model zoo
  cfg.SOLVER.IMS_PER_BATCH = 2
  cfg.SOLVER.BASE_LR = 0.01
  cfg.MODEL.ANCHOR_GENERATOR.SIZES = [[8,16,32]]
  cfg.MODEL.ANCHOR_GENERATOR.ANGLES = [[0,90]]
  cfg.SOLVER.MAX_ITER = (
      300
  )  # 300 iterations seems good enough, but you can certainly train longer
  cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = (
      16
  )  # faster, and good enough for this toy dataset
  cfg.MODEL.ROI_HEADS.NUM_CLASSES = 4  # 7 classes (none, error, pup, adult male, subadult male, female, juvenile)
  
  print(&quot;Start training&quot;)
  os.makedirs(cfg.OUTPUT_DIR, exist_ok=True)
  trainer = DefaultTrainer(cfg)
  trainer.resume_or_load(resume=False)
  trainer.train()
  </code></pre>
  <p>The full error is</p>
  <pre><code>ERROR [08/09 01:39:54 d2.engine.train_loop]: Exception during training:
  Traceback (most recent call last):
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/engine/train_loop.py&quot;, line 149, in train
      self.run_step()
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/engine/defaults.py&quot;, line 494, in run_step
      self._trainer.run_step()
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/engine/train_loop.py&quot;, line 274, in run_step
      loss_dict = self.model(data)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/modeling/meta_arch/rcnn.py&quot;, line 158, in forward
      features = self.backbone(images.tensor)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/modeling/backbone/fpn.py&quot;, line 139, in forward
      bottom_up_features = self.bottom_up(x)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/modeling/backbone/resnet.py&quot;, line 445, in forward
      x = self.stem(x)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/modeling/backbone/resnet.py&quot;, line 356, in forward
      x = self.conv1(x)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/torch/nn/modules/module.py&quot;, line 889, in _call_impl
      result = self.forward(*input, **kwargs)
    File &quot;/home/hysterio/.pyenv/versions/3.7.6/envs/vivadata/lib/python3.7/site-packages/detectron2/layers/wrappers.py&quot;, line 114, in forward
      x, self.weight, self.bias, self.stride, self.padding, self.dilation, self.groups
  RuntimeError: Input type (torch.cuda.DoubleTensor) and weight type (torch.cuda.FloatTensor) should be the same
  [08/09 01:39:54 d2.engine.hooks]: Total training time: 0:00:00 (0:00:00 on hooks)
  [08/09 01:39:55 d2.utils.events]:  iter: 0    lr: N/A  max_mem: 249M
  </code></pre>