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.2.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.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mps_watch-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 8617b89bd2d5e5ad7a4e8cb45f81bc244d05f38cd3e750b7d90e548303486dc8
MD5 dbdd2e361c25dbf30e10de5b310760e6
BLAKE2b-256 f3c13defbe392b8fa06aa34ceacb45a65e41c9e512f4aae175e4eed30ae710bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mps_watch-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c10e34fcfedbaae3b29572ea50462584e08fb18cfc47ccd656f536a34514483
MD5 bb154a686f1dbbfc80b43e30da2ac542
BLAKE2b-256 78b03858375e3cb158d2e11e9c5c60afdce99201c22baa41c8a3362d07754a8e

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