bennyguo / instant-nsr-pl

Neural Surface reconstruction based on Instant-NGP. Efficient and customizable boilerplate for your research projects. Train NeuS in 10min!
MIT License
856 stars 84 forks source link

RuntimeError: expected scalar type double but found float #95

Open lxr319 opened 1 year ago

lxr319 commented 1 year ago

Thanks for your excellent work, I encountered the following problem, how to resolve it? When I run the command " python launch.py --config configs/neus-dtu.yaml --gpu 0 --train" , the log is :

Epoch 0: : 0it [00:00, ?it/s]Traceback (most recent call last): File "launch.py", line 125, in main() File "launch.py", line 114, in main trainer.fit(system, datamodule=dm) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 579, in fit call._call_and_handle_interrupt( File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/call.py", line 36, in _call_and_handle_interrupt return trainer.strategy.launcher.launch(trainer_fn, *args, trainer=trainer, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/strategies/launchers/subprocess_script.py", line 90, in launch return function(*args, *kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 621, in _fit_impl self._run(model, ckpt_path=self.ckpt_path) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1058, in _run results = self._run_stage() File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1137, in _run_stage self._run_train() File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1160, in _run_train self.fit_loop.run() File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run self.advance(args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/fit_loop.py", line 267, in advance self._outputs = self.epoch_loop.run(self._data_fetcher) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run self.advance(*args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py", line 214, in advance batch_output = self.batch_loop.run(kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run self.advance(*args, *kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/batch/training_batch_loop.py", line 88, in advance outputs = self.optimizer_loop.run(optimizers, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/loop.py", line 199, in run self.advance(args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 200, in advance result = self._run_optimization(kwargs, self._optimizers[self.optim_progress.optimizer_position]) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 247, in _run_optimization self._optimizer_step(optimizer, opt_idx, kwargs.get("batch_idx", 0), closure) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 357, in _optimizer_step self.trainer._call_lightning_module_hook( File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1302, in _call_lightning_module_hook output = fn(*args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/core/module.py", line 1661, in optimizer_step optimizer.step(closure=optimizer_closure) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/core/optimizer.py", line 169, in step step_output = self._strategy.optimizer_step(self._optimizer, self._optimizer_idx, closure, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/strategies/ddp.py", line 281, in optimizer_step optimizer_output = super().optimizer_step(optimizer, opt_idx, closure, model, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/strategies/strategy.py", line 234, in optimizer_step return self.precision_plugin.optimizer_step( File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/plugins/precision/native_amp.py", line 85, in optimizer_step closure_result = closure() File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 147, in call self._result = self.closure(*args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 133, in closure step_output = self._step_fn() File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/loops/optimization/optimizer_loop.py", line 406, in _training_step training_step_output = self.trainer._call_strategy_hook("training_step", kwargs.values()) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1440, in _call_strategy_hook output = fn(args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/strategies/ddp.py", line 352, in training_step return self.model(*args, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 886, in forward output = self.module(*inputs[0], *kwargs[0]) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/pytorch_lightning/overrides/base.py", line 98, in forward output = self._forward_module.training_step(*inputs, kwargs) File "/home/autel/code/instant-nsr-pl/systems/neus.py", line 89, in training_step out = self(batch) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/home/autel/code/instant-nsr-pl/systems/neus.py", line 32, in forward return self.model(batch['rays']) File "/home/autel/anaconda3/envs/instant-nsr-pl/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "/home/autel/code/instant-nsr-pl/models/neus.py", line 291, in forward out = self.forward(rays) File "/home/autel/code/instant-nsr-pl/models/neus.py", line 269, in forward out_bg = self.forwardbg(rays) File "/home/autel/code/instant-nsr-pl/models/neus.py", line 157, in forwardbg near_plane = torch.where(t_max > 1e9, self.near_plane_bg, t_max) RuntimeError: expected scalar type double but found float Epoch 0: : 0it [00:03, ?it/s] But When I run the command " python launch.py --config configs/neus-dtu-wask.yaml --gpu 0 --train",it can run normally In other words, running without mask will cause this error cuda:11.1 torch:1.10.0 +cu111 Lightning:1.8.0 Nerfacc:0.3.3 tinycudann:1.7