Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
See original GitHub issueHi there! Thanks for your great repo, but i faced with some difficulties while trying to inference on device (‘cuda:0’). My code:
device = torch.device('cuda:0')
tfms = transforms.Compose([transforms.Resize(224), transforms.ToTensor(), transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),])
img = tfms(Image.open('img.png')).unsqueeze(0)
img.to(device)
model.to(device)
model.eval()
with torch.no_grad(): outputs = model(img)
And thrown error:
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
RuntimeError: Input type (torch.FloatTensor) and weight type ...
You get this error because your model is on the GPU, but your data is on the CPU. So, you need to send...
Read more >Input type (torch.FloatTensor) and weight ... - PyTorch Forums
FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor.
Read more >RuntimeError: Input type (torch.cuda ... - Fast.ai forums
I get the following error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same.
Read more >Runtime error Input type (torch.cuda.FloatTensor) and weight ...
FloatTensor) and weight type (torch. FloatTensor) should be the same. I'm trying to train my model but I encounter this error message. From...
Read more >Fine-Tune Wav2Vec2 for English ASR on GCP ... - GitHub
FloatTensor) and weight type (torch.cuda.HalfTensor) should be the same or input should be a MKLDNN tensor and weight is a dense tensor #255....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, i didn’t understand your answer. Thank you very much,
So it’s impossibile to run on GPU or i missed something?