Skip to main content

Apple Silicon MPS (Metal Performance Shaders) memory monitoring tool for PyTorch.

Project description

mps-watch

The Apple Silicon equivalent of nvidia-smi or gpustat for PyTorch. Monitor your MPS (Metal Performance Shaders) memory usage in real-time.

Features

  • Python API: Context manager and decorator for tracking VRAM usage of specific code blocks.
  • CLI Tool: Terminal-based dashboard for system unified memory monitoring.
  • Safe Fallbacks: Graceful handling on non-Mac systems or without MPS.

Installation

pip install mps-watch

Usage

Python API

Monitor memory usage of specific blocks or functions:

from mps_watch import monitor
import torch

# As context manager
with monitor("Training Block"):
    # Your MPS code here
    model.to("mps")
    output = model(input)

# As decorator
@monitor("Inference")
def predict(x):
    return model(x)

# Get current usage directly
from mps_watch import get_current_memory_usage, get_system_memory

allocated, reserved = get_current_memory_usage()
print(f"Current Allocated: {allocated} bytes")

# Get system-wide unified memory
sys_mem = get_system_memory()
print(f"System Total: {sys_mem['total']} bytes")
print(f"System Used: {sys_mem['used']} bytes")

Output: It will print a table showing Initial, Final, and Delta memory usage (Allocated vs Reserved).

CLI Tool

Run the dashboard in your terminal:

mps-watch

This will show a live-updating dashboard of your System Unified Memory and MPS availability status.

Requirements

  • macOS 12.3+ (for MPS support)
  • Python 3.8+
  • PyTorch
  • rich
  • psutil

Understanding the Stats

CLI vs Python API

  • The CLI Tool (mps-watch): Shows System-wide memory usage. Since Apple Silicon uses Unified Memory, this reflects the total RAM used by the OS and all applications combined. It gives you an idea of the overall system pressure.
  • The Python API (monitor / get_current_memory_usage): Shows Process-specific MPS memory usage. This is the amount of memory specifically allocated by PyTorch on the Metal device for your script.

Why are they different? The CLI shows the whole pie (System RAM). The Python API shows just your slice (PyTorch MPS Usage).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mps_watch-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mps_watch-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mps_watch-0.1.1.tar.gz.

File metadata

  • Download URL: mps_watch-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mps_watch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 598d9015e1a863e73bd204420601cb12bca06989aaae897fd53aa670989facb0
MD5 3c225f1aa57475de6ef543e73397d275
BLAKE2b-256 4482c67f210890cd8640ffe26b6b2e40e8b98ea0ab6368cd4c4d6fa4260bd481

See more details on using hashes here.

File details

Details for the file mps_watch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mps_watch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mps_watch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21f5e2458d9a405fc417d0fecc1e3c4218a5e8b968b71c72a4741abf4553d1cf
MD5 d4ae4e125052cc1fb3db6a097678bdcc
BLAKE2b-256 2211fdaf77a32dff64867953b10af8ae47d4be5dda1dd6cc339bf95bb51ac7ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page