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

cast background to device #2381

Merged
merged 2 commits into from
Aug 29, 2023
Merged

Conversation

Mxbonn
Copy link
Contributor

@Mxbonn Mxbonn commented Aug 29, 2023

running ns-train vanilla-nerf resulted in the following error:

Traceback (most recent call last):
  File "/usr/local/bin/ns-train", line 8, in <module>
    sys.exit(entrypoint())                                 
  File "/project_ghent/projects/nerfstudio/nerfstudio/scripts/train.py", line 261, in entrypoint
    main(                                                  
  File "/project_ghent/projects/nerfstudio/nerfstudio/scripts/train.py", line 246, in main
    launch(                                                
  File "/project_ghent/projects/nerfstudio/nerfstudio/scripts/train.py", line 189, in launch
    main_func(local_rank=0, world_size=world_size, config=config)
  File "/project_ghent/projects/nerfstudio/nerfstudio/scripts/train.py", line 100, in train_loop
    trainer.train()                                        
  File "/project_ghent/projects/nerfstudio/nerfstudio/engine/trainer.py", line 255, in train
    loss, loss_dict, metrics_dict = self.train_iteration(step)
  File "/project_ghent/projects/nerfstudio/nerfstudio/utils/profiler.py", line 127, in inner
    out = func(*args, **kwargs)
  File "/project_ghent/projects/nerfstudio/nerfstudio/engine/trainer.py", line 474, in train_iteration
    _, loss_dict, metrics_dict = self.pipeline.get_train_loss_dict(step=step)
  File "/project_ghent/projects/nerfstudio/nerfstudio/utils/profiler.py", line 127, in inner
    out = func(*args, **kwargs)
  File "/project_ghent/projects/nerfstudio/nerfstudio/pipelines/base_pipeline.py", line 299, in get_train_loss_dict
    model_outputs = self._model(ray_bundle)  # train distributed data parallel model if world_size > 1
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1533, in _call_impl
    return forward_call(*args, **kwargs)
  File "/project_ghent/projects/nerfstudio/nerfstudio/models/base_model.py", line 142, in forward
    return self.get_outputs(ray_bundle)
  File "/project_ghent/projects/nerfstudio/nerfstudio/models/vanilla_nerf.py", line 156, in get_outputs
    rgb_coarse = self.renderer_rgb(
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1533, in _call_impl
    return forward_call(*args, **kwargs)
  File "/project_ghent/projects/nerfstudio/nerfstudio/model_components/renderers.py", line 229, in forward
    rgb = self.combine_rgb(                                
  File "/project_ghent/projects/nerfstudio/nerfstudio/model_components/renderers.py", line 119, in combine_rgb
    comp_rgb = comp_rgb + background_color * (1.0 - accumulated_weight)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

This pull request fixes this error by casting the background_color to the same device as the comp_rgb.

@tancik tancik merged commit 242c23f into nerfstudio-project:main Aug 29, 2023
4 checks passed
@Mxbonn Mxbonn deleted the background_to_device branch August 30, 2023 07:06
maturk pushed a commit that referenced this pull request Sep 11, 2023
* cast background_color to device

* make onliner instead
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

Successfully merging this pull request may close these issues.

None yet

2 participants