Skip to content

Add Apple Silicon MPS support to predict.py - #24

Open
javahedi wants to merge 2 commits into
qaz812345:masterfrom
javahedi:feature/apple-silicon-mps-support
Open

Add Apple Silicon MPS support to predict.py#24
javahedi wants to merge 2 commits into
qaz812345:masterfrom
javahedi:feature/apple-silicon-mps-support

Conversation

@javahedi

@javahedi javahedi commented Sep 1, 2026

Copy link
Copy Markdown

Summary

This PR adds automatic PyTorch device selection to predict.py, allowing TrackNetV3 inference to run on Apple Silicon using the MPS backend.

The device is selected in the following order:

  • CUDA, when available
  • MPS, when available on Apple Silicon
  • CPU as a fallback

Hardcoded .cuda() calls are replaced with .to(device) so the existing CUDA workflow remains supported while making inference portable to macOS/Apple Silicon.

Motivation

The current prediction script assumes an NVIDIA CUDA environment, which prevents it from running directly on Apple Silicon Macs.

This change keeps the existing behavior for CUDA users while enabling TrackNetV3 inference through PyTorch MPS.

Testing

  • Python syntax checked with python -m py_compile predict.py
  • Verified no remaining hardcoded .cuda() calls in predict.py

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