Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #93

Open
JianingHe0115 opened this issue Jun 1, 2023 · 3 comments

Comments

@JianingHe0115
Copy link

Hi! I try to run my data in DS-nerf, but it always has this runtime error. How to solve this problem?

0% 0/1 [00:00<?, ?it/s]0 0.0003409385681152344
/usr/local/lib/python3.10/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.)
return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]
torch.Size([1080, 1920, 3]) torch.Size([1080, 1920])
max: 0.9995105
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.

100% 1/1 [03:54<00:00, 234.32s/it]
Saved test set
10% 4999/50000 [29:18<4:23:50, 2.84it/s]

Traceback (most recent call last):
File "/content/drive/MyDrive/DSNeRF/run_nerf.py", line 1134, in
train()
File "/content/drive/MyDrive/DSNeRF/run_nerf.py", line 1080, in train
test_loss = img2mse(torch.Tensor(rgbs), images[i_test])
File "/content/drive/MyDrive/DSNeRF/run_nerf_helpers.py", line 17, in
img2mse = lambda x, y : torch.mean((x - y) ** 2)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

@dunbar12138
Copy link
Owner

Hi, it seems rgbs and images are on different devices. Maybe you want to move them to the same one.

@JianingHe0115
Copy link
Author

I've already solved this problem. Thank you!

@shounaknaik
Copy link

@JianingHe0115 can you please share your solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants