{"id":5553,"library":"xprof","title":"XProf Profiler Plugin","description":"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.","status":"active","version":"2.22.1","language":"en","source_language":"en","source_url":"https://github.com/openxla/xprof","tags":["profiling","machine learning","jax","tensorflow","pytorch","xla","tpu","gpu","cpu","performance"],"install":[{"cmd":"pip install xprof","lang":"bash","label":"Basic installation"},{"cmd":"pip install xprof tensorboard","lang":"bash","label":"With TensorBoard plugin"}],"dependencies":[{"reason":"Optional: Provides a UI for visualizing profiles as an XProf plugin.","package":"tensorboard","optional":true},{"reason":"Direct dependency for certain profiling tools (HLO Op Profile, Trace Viewer, Graph Viewer) when profiling TPUs. Specific versions have known regressions.","package":"libtpu","optional":false}],"imports":[],"quickstart":{"code":"# 1. Collect profile data (example using JAX profiler, actual collection varies by framework)\n# In your ML training code (e.g., JAX):\n# import jax.profiler\n# jax.profiler.start_server(9012)\n# ... run your model ...\n# jax.profiler.stop_server()\n\n# 2. Run XProf as a standalone server to view collected profiles\n# Assuming profile data is saved to 'profiler/demo' directory:\n# To run XProf standalone:\nxprof --logdir=profiler/demo --port=6006\n\n# Or, to view with TensorBoard (if installed):\ntensorboard --logdir=profiler/demo","lang":"bash","description":"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."},"warnings":[{"fix":"As a temporary workaround, use `libtpu 0.0.36`. This issue has been acknowledged and is being resolved by the developers.","message":"A known regression in `libtpu` versions `0.0.35` and `0.0.37` causes tools dependent on HLO Modules (e.g., HLO Op Profile, Trace Viewer, Graph Viewer) to not work as intended across all XProf versions. This significantly impacts core visualization features.","severity":"breaking","affected_versions":">=2.22.0"},{"message":"XProf requires internet access to load the Google Chart library. If running offline, behind a corporate firewall, or in a datacenter without external access, some charts and tables in the UI may be missing or fail to load.","severity":"gotcha"},{"fix":"Install an older version of setuptools: `pip install \"setuptools<70\"`.","message":"Python 3.12+ users may encounter a `ModuleNotFoundError: No module named 'pkg_resources'` during installation or runtime due to changes in Python's packaging system.","severity":"gotcha","affected_versions":">=2.20.0 (with Python 3.12+)"},{"fix":"Try downgrading the `protobuf` package to `3.20.x` or lower, or set the environment variable `PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python` (though this might impact performance). Ensure your `tensorflow` and `tensorboard` versions are compatible with `xprof`.","message":"When used with TensorBoard, version conflicts with the `protobuf` package (a common dependency for TensorFlow/TensorBoard) can lead to `TypeError: Descriptors cannot be created directly`. This indicates potential incompatibility with specific `tensorflow` or `tensorboard` versions.","severity":"gotcha","affected_versions":"All versions, especially with older `tensorflow`/`tensorboard` dependencies."}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}