I met a problem when I run pytorch code:
RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #4 ‘mat1’.
That error means the net need torch.cuda.Tensor but I gave a torch.Tensor. However, before I send the data into the net, I have already copy the data to GPU memory, the error still occurs, Anyone can give a suggestion?
the error code is below:
net = net.cuda()
net = DataParallel(net)
for i, (data,target) in enumerate(dataloader):
if torch.cuda.is_available():
data = data.cuda()
target = target.cuda()
output = net(data)
…
I have already set the environment variable CUDA_VISIBLE_DEVICES
my pytorch version is 0.4.0