I want to train my I3D network with GPU but got following error.
Traceback (most recent call last):
File "train_sample.py", line 329, in <module>
model_conv = train_model(rgb_i3d, criterion, optimizer,exp_lr_scheduler, num_epochs=5)
File "train_sample.py", line 287, in train_model
rbg_score, rgb_logits = rgb_i3d(inputs)
File "/home/caglar/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/caglar/train-i3d/I3D_Pytorch.py", line 313, in forward
logits = self.features(x)
File "/home/caglar/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/caglar/.local/lib/python3.6/site-packages/torch/nn/modules/container.py", line 92, in forward
input = module(input)
File "/home/caglar/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in __call__
result = self.forward(*input, **kwargs)
File "/home/caglar/.local/lib/python3.6/site-packages/torch/nn/modules/conv.py", line 480, in forward
self.padding, self.dilation, self.groups)
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
This is the network that I used for train.
And this is related part of my codes
device = torch.device( "cuda:0" if torch.cuda.is_available() else "cpu")
#torch.cuda.is_available() return True in my compter
rgb_i3d = I3D(num_classes=NUM_CLASSES , input_channel=3)
rgb_i3d = rgb_i3d.to(device)
state_dict = torch.load(_CHECKPOINT_PATHS)
rgb_i3d.load_state_dict(state_dict)
for inputs, labels in dataloader:
inputs = inputs.to(device)
rbg_score, rgb_logits = rgb_i3d(inputs) #there is where my error occur
What is the problem? How can I fix it?