Skip to content

Prevent hardcoded 'cpu' device - use config file #112

@rogermt

Description

@rogermt

Problem

The YOLO plugin has 70+ occurrences of hardcoded "cpu" as the default device parameter. This causes the plugin to run on CPU even when the config file (models.yaml) specifies device: "cuda".

Locations affected:

  • plugin.py - Tool function defaults, manifest schema defaults
  • inference/*.py - All detection/tracking functions
  • video/*.py - All video processing functions
  • utils/team.py - Team classification

Current workaround:

The run_tool() method now reads from config, but if someone calls the underlying functions directly, they'll still get CPU.

Proposed Solution

  1. Add a CI check to prevent new hardcoded "cpu" defaults:

    • Create a script that scans for device: str = "cpu" patterns
    • Fail CI if found outside of config fallback
  2. Refactor to use config throughout:

    • Create a get_default_device() helper in configs/__init__.py
    • Replace all device: str = "cpu" with device: str = get_default_device()
  3. Document the pattern:

    • Add to plugin development guide
    • Ensure all plugins follow the same pattern

Impact

  • GPU acceleration not working by default on GPU-enabled systems
  • Performance degradation on Kaggle/Colab where GPU is expected
  • Confusing UX when config file is ignored

Priority

High - Affects core functionality (GPU vs CPU inference)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions