Both tensors are on same device but raises an error both aren't #607
Answered
by
SkafteNicki
ThiruRJST
asked this question in
Classification
-
I'm using torchmetrics to calculate the accuracy of model in pytorch but it raises an error that the tensors aren't in the same device. Actually both the tensors are in same device. ERROR: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! Is this a bug or have I made any mistakes? |
Beta Was this translation helpful? Give feedback.
Answered by
SkafteNicki
Nov 8, 2021
Replies: 1 comment 1 reply
-
Copy of #608 (comment) The solution is to move your metrics to the correct device (similar to you moving model and data). So instead of metric = torchmetrics.Accuracy() do metric = torchmetrics.Accuracy().to(device) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
SkafteNicki
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy of #608 (comment)
The solution is to move your metrics to the correct device (similar to you moving model and data). So instead of
do