dunbar12138 / DSNeRF

Code release for DS-NeRF (Depth-supervised Neural Radiance Fields)
https://www.cs.cmu.edu/~dsnerf/
MIT License
746 stars 126 forks source link

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

Open JianingHe0115 opened 1 year ago

JianingHe0115 commented 1 year ago

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 commented 1 year ago

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

JianingHe0115 commented 1 year ago

I've already solved this problem. Thank you!

shounaknaik commented 6 months ago

@JianingHe0115 can you please share your solution?