Skip to content

Fix RuntimeError in loc_inference.py when using --data_device cpu#13

Open
YunSeok-Kang wants to merge 1 commit into
be2rlab:mainfrom
YunSeok-Kang:main
Open

Fix RuntimeError in loc_inference.py when using --data_device cpu#13
YunSeok-Kang wants to merge 1 commit into
be2rlab:mainfrom
YunSeok-Kang:main

Conversation

@YunSeok-Kang

Copy link
Copy Markdown

Description

This PR fixes a RuntimeError: Expected all tensors to be on the same device that occurs during localization inference (loc_inference.py) when the model is trained with --data_device cpu.

Motivation and Context

When training with --data_device cpu to save VRAM, the ground truth images (qr) remain on the CPU. However, the rendered images (warped_image) are computed on the GPU. This causes a device mismatch in compute_warping_loss when calculating F.mse_loss.

How has this been tested?

I trained the model on the 7Scenes Chess dataset using --data_device cpu and ran loc_inference.py.

  • Before fix: Crashed with RuntimeError at warping_loss.py.
  • After fix: Localization inference completes successfully without errors.

Changes

  • Added a check in warping/warping_loss.py to move the target tensor (qr) to the same device as the input tensor (warped_image) before loss calculation.

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.

1 participant