I am getting this error of Float.Tensor and cuda.FloatTenson mismatch
I am getting this error while running the training code of a model.
Traceback (most recent call last):
  File &quot;train.py&quot;, line 273, in &lt;module&gt;
    train_loss[epoch - 1] = process_epoch(
  File &quot;train.py&quot;, line 240, in process_epoch
    loss = loss_fn(model, batch)
  File &quot;train.py&quot;, line 221, in &lt;lambda&gt;
    loss_fn = lambda model, batch: weak_loss(model, batch, normalization=&quot;softmax&quot;)
  File &quot;train.py&quot;, line 171, in weak_loss
    corr4d = model(batch).to(&quot;cuda&quot;)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/home/srtf/ncnet/lib/model.py&quot;, line 263, in forward
    feature_A = self.FeatureExtraction(tnf_batch['source_image'])
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/home/srtf/ncnet/lib/model.py&quot;, line 84, in forward
    features = self.model(image_batch)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/container.py&quot;, line 100, in forward
    input = module(input)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/module.py&quot;, line 550, in __call__
    result = self.forward(*input, **kwargs)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/conv.py&quot;, line 353, in forward
    return self._conv_forward(input, self.weight)
  File &quot;/home/srtf/anaconda3/envs/ncnet/lib/python3.8/site-packages/torch/nn/modules/conv.py&quot;, line 349, in _conv_forward
    return F.conv2d(input, weight, self.bias, self.stride,
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

Cuda is there on the system. Where do I need to make changes in the code?

Your input needs to be sent to the correct device:
&gt;&gt;&gt; corr4d = model(batch.cuda())

Which will copy the batch to the GPU device ('cuda:0' by default).
