Skip to content

fix: remove hardcoded CPU device in VLM_COCO_Local#2468

Open
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:feat/local-inference-gpu-support
Open

fix: remove hardcoded CPU device in VLM_COCO_Local#2468
Wanbogang wants to merge 2 commits intoOpenMind:mainfrom
Wanbogang:feat/local-inference-gpu-support

Conversation

@Wanbogang
Copy link
Copy Markdown
Contributor

Problem

VLM_COCO_Local had self.device hardcoded to "cpu", which means
GPU was never utilized even when CUDA is available. This caused
unnecessarily slow local inference on machines with a dedicated GPU.

# Before
self.device = "cpu"  # GPU ignored entirely

Solution

Replace the hardcoded value with automatic device detection using
PyTorch's built-in torch.cuda.is_available():

# After
self.device = "cuda" if torch.cuda.is_available() else "cpu"
logging.info(f"COCO Object Detector using device: {self.device}")
  • If CUDA is available → uses GPU automatically
  • If no GPU → falls back to CPU silently
  • No breaking changes to existing behavior

Changes

  • src/inputs/plugins/vlm_coco_local.py — replace hardcoded "cpu" with auto-detection
  • tests/inputs/plugins/test_vlm_coco_local.py — mock torch.cuda.is_available() to ensure consistent CI behavior regardless of hardware

@Wanbogang Wanbogang requested review from a team as code owners March 12, 2026 11:12
@github-actions github-actions bot added robotics Robotics code changes python Python code tests Test files config Configuration files labels Mar 12, 2026
VLM_COCO_Local had self.device hardcoded to 'cpu', preventing GPU
utilization even when CUDA is available. This fix auto-detects the
optimal device at initialization and logs the selected device.

- Replace hardcoded 'cpu' with torch.cuda.is_available() check
- Add logging to show which device is selected at startup
- Update tests to mock GPU detection for consistent CI behavior
@Wanbogang Wanbogang force-pushed the feat/local-inference-gpu-support branch from 33920c1 to a50f4c8 Compare March 12, 2026 11:15
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration files python Python code robotics Robotics code changes tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant