JeffWang987 / MVSTER

[ECCV 2022] MVSTER: Epipolar Transformer for Efficient Multi-View Stereo
MIT License
189 stars 13 forks source link

RUN train_mvs4.py #3

Open Innocence4822 opened 2 years ago

Innocence4822 commented 2 years ago

很抱歉打扰您,在运行程序时遇到了问题,想向您请教一下: 当我运行train_mvs4.py时出现了下面的问题: Traceback (most recent call last): File "/home/ly/Work/MVSTER/train_mvs4.py", line 425, in train(model, model_loss, optimizer, TrainImgLoader, TestImgLoader, start_epoch, args) File "/home/ly/Work/MVSTER/train_mvs4.py", line 103, in train loss, scalar_outputs, image_outputs = train_sample(model, model_loss, optimizer, sample, args) File "/home/ly/Work/MVSTER/train_mvs4.py", line 207, in train_sample outputs = model(sample_cuda["imgs"], sample_cuda["proj_matrices"], sample_cuda["depth_values"]) File "/home/ly/anaconda3/envs/MVSTER/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, kwargs) File "/home/ly/anaconda3/envs/MVSTER/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], *kwargs[0]) File "/home/ly/anaconda3/envs/MVSTER/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, kwargs) File "/home/ly/Work/MVSTER/models/MVS4Net.py", line 97, in forward depth_hypo = schedule_range(outputs_stage['depth'].detach(), self.stage_splits[stage_idx], self.depth_interals_ratio[stage_idx] depth_interval, H, W) File "/home/ly/Work/MVSTER/models/mvs4net_utils.py", line 97, in schedule_range requires_grad=False).reshape(1, -1, 1, 1) new_interval.unsqueeze(1)) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! 请问这个问题怎么解决呀

doubleZ0108 commented 2 years ago

Hi, this problem also occurs when I use the NO inverse_depth flag for training. After digging into the error message, I find that the original code provided by this repo transfers depth_max and depth_min Tensor into Numpy(CPU) which lead to the aforementioned issue. In MVS4Net.py line 61~62, remove .cpu().numpy(), and is looks good in my case.