question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

See original GitHub issue

Hi 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:closed
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
litvinichcommented, Jul 27, 2019

Sorry, i didn’t understand your answer. Thank you very much,

1reaction
litvinichcommented, Jul 26, 2019

So it’s impossibile to run on GPU or i missed something?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found