ryan_stark:

I got a RuntimeError: Expected object of type torch.DoubleTensor but found type torch.cuda.FloatTensor for


Is it maybe a documentation error and it meant to say the opposite, like your model correctly wants a torch.cuda.FloatTensor but got a torch.DoubleTensor from the training data? It seems that cuda is at least partly working, either for your model or your training data. Maybe you forgot to also cast your input data and this is a typo in the error message? (A long shot, but maybe worth trying if you haven’t yet)
E.g., in general, it would be sth like this
D = Discriminator().to(device=device)    

for batch_idx, (features, targets) in enumerate(train_loader):
    
    features = features.to(device)
    targets = targets.to(device)
    logits, probas = D(features)

EDIT:

Expected object of type torch.DoubleTensor but found type torch.cuda.FloatTensor for argument #2 ‘weight’ when i try to train a DCGAN. It remind me that my input`s type is torch.cuda.FloatTensor,

Oh, wait, couldn’t be argument #1 the input data and like you show in your later comment,
>>> print(model[0].weight.type())
torch.cuda.FloatTensor

seems to be correctly using cuda, so that argument #1, the input data would be the input data the weight gets matrix-multiplied with, which is probably a torch.DoubleTensor (in case you haven’t used to(device) on that one as well)