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.0.tar.gz (4.5 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.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mps_watch-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mps_watch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b474ee3343db3d9e6ce0f811b2181e6023410b5c4fad3cf8527554ffacd6752e
MD5 43d4aedf12da3f40f8f98d8f5cf17a7a
BLAKE2b-256 8d8e62d3ef06400c0645e9f0819a626f79a78858e669b00cb0b14414a30ffe99

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mps_watch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e89e815bb0806f9766a21643025a7ac20b05953c60923a7c50bf35ebf414fde
MD5 bf8f4a5feb11bd3358ab0e322b1c0b89
BLAKE2b-256 ae4b7d0ce3a94517b5eeba83c05028cebb103a1747add28e0b7d28c9232ec04b

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