I get an error at the outputs assignment.
“RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #4 ‘mat1’”
I get, erring on the same last line of code, the “opposite error”:
“RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #4 ‘mat1’”
However, if I remove all “to(device)” then the code runs fine.
What might be going on here?
Thank you.
I’m using version 0.4.1.
Your example did work for me. I’ll try to create a minimal reproducible script as soon as I can.
However, I also wonder in generally what dictates the kind of input that a custom defined net is expecting. In your case, while you saved a layer in a variable called “net”, it’s not of the Module class, which I suspect might be relevant.
Is sending a net “to(device)” which is cuda an if and only if condition for it to expect cuda input?
Just for the sake of archival conclusion I’ll say that I went back to the same code, and I managed to run it with Cuda. Apparently I just didn’t append".to(device)" to all necessary variables.
I’d say the error messages were not so informative, but I think that’s a known issue already (I remember reading people mentioning it, probably on this here forum). Perhaps it was solved on the 1.0 version which I had not the pleasure yet to try.
@Konotori About Arul’s answer, layer is actually a subclass of Module, so it is relevant.
May I ask what variable you missed to append .to(device) to? It seems you already get the input and model on cuda.