Hi Simon:joy:, I am just encountering a very similar issue while I have already put my network on cuda by

model = torch.nn.DataParallel(model).cuda()

and my input and target on cuda by

inputs, targets = inputs.cuda(), targets.cuda(async=True)

while I still have the problem of

RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #4 ‘other’

If that means there are still something I forget? Thank you for your time to read my question!
The full error message:

File “cifar.py”, line 347, in 
main()
File “cifar.py”, line 202, in main
train_loss, train_acc = train(trainloader, model, criterion, optimizer, epoch, use_cuda)
File “cifar.py”, line 247, in train
outputs = model(inputs)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\parallel\data_parallel.py”, line 112, in forward
return self.module(*inputs[0], **kwargs[0])
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “D:\pycharm\WORKS\VSBNet_pytorch\pytorch-classification-master\models\cifar\vgg_bi.py”, line 32, in forward
x = self.features(x)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\container.py”, line 91, in forward
input = module(input)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\module.py”, line 491, in call
result = self.forward(*input, **kwargs)
File “D:\pycharm\WORKS\venv\lib\site-packages\torch\nn\modules\conv.py”, line 168, in forward
torch.sum(tmp_tensor)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #4 ‘other’

and my code (I am doing some modify in the source code “conv.py” in torch.nn.Module):

self.Bi_weight[channal] += torch.sign(tmp_tensor * self.weight[channal]) * 
torch.sum(tmp_tensor * torch.abs(self.weight[channal])) / 
torch.sum(tmp_tensor)


tmp_tensor = ((torch.abs(
self.weight[channal]) >= sep_point(i, self.group_num)) *
(torch.abs(self.weight[channal]) < sep_point(i+1, self.group_num))).float().cuda()