XProf Profiler Plugin

2.22.1 · active · verified Mon Apr 13

XProf is a comprehensive profiling and performance analysis tool for machine learning workloads. It supports frameworks such as JAX, TensorFlow, and PyTorch/XLA, running on various hardware including CPUs, GPUs, and TPUs. The library offers a suite of tools like Overview, Trace Viewer, Memory Profile Viewer, and Graph Viewer to aid in understanding, debugging, and optimizing ML programs. It is actively maintained with frequent minor and patch releases.

Warnings

Install

Quickstart

XProf is primarily used as a command-line tool or a TensorBoard plugin. First, ensure your machine learning workload is configured to capture profile data to a specified directory (e.g., `profiler/demo`). Then, launch XProf either as a standalone web server or through TensorBoard to visualize the collected profiles. The provided code demonstrates launching XProf from the command line, either directly or via TensorBoard.

# 1. Collect profile data (example using JAX profiler, actual collection varies by framework)
# In your ML training code (e.g., JAX):
# import jax.profiler
# jax.profiler.start_server(9012)
# ... run your model ...
# jax.profiler.stop_server()

# 2. Run XProf as a standalone server to view collected profiles
# Assuming profile data is saved to 'profiler/demo' directory:
# To run XProf standalone:
xprof --logdir=profiler/demo --port=6006

# Or, to view with TensorBoard (if installed):
tensorboard --logdir=profiler/demo

view raw JSON →