kornia / tutorials

Repository containing the Kornia related tutorials
https://kornia.github.io/tutorials/
Apache License 2.0
45 stars 32 forks source link

Expected all tensors to be on the same device, but found at least two devices #21

Closed robmarkcole closed 3 years ago

robmarkcole commented 3 years ago

In homography.ipynb I get:

models_to_final = [torch.eye(3)[None]]
for m in models[::-1]:
    models_to_final.append(m @ models_to_final[-1])
models_to_final = models_to_final[::-1]

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-7-1f078b01c096> in <module>()
      1 models_to_final = [torch.eye(3)[None]]
      2 for m in models[::-1]:
----> 3     models_to_final.append(m @ models_to_final[-1])
      4 models_to_final = models_to_final[::-1]

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking arugment for argument mat2 in method wrapper_bmm)

Appears to be https://stackoverflow.com/questions/64929665/pytorch-running-runtimeerror-expected-all-tensors-to-be-on-the-same-device-bu

robmarkcole commented 3 years ago

Solution:

models_to_final = [torch.eye(3).to(device)[None]]
ducha-aiki commented 3 years ago

Thanks again! Fixed in https://github.com/kornia/tutorials/commit/2f1c5e2f399d99d39faf51d0583672f185f1a38a, let the website a couple of minutes to update from the source