Skip to main content

XProf Profiler Plugin

Project description

XProf (+ Tensorboard Profiler Plugin)

XProf offers a number of tools to analyse and visualize the performance of your model across multiple devices. Some of the tools include:

  • Overview: A high-level overview of the performance of your model. This is an aggregated overview for your host and all devices. It includes:
    • Performance summary and breakdown of step times.
    • A graph of individual step times.
    • High level details of the run environment.
  • Trace Viewer: Displays a timeline of the execution of your model that shows:
    • The duration of each op.
    • Which part of the system (host or device) executed an op.
    • The communication between devices.
  • Memory Profile Viewer: Monitors the memory usage of your model.
  • Graph Viewer: A visualization of the graph structure of HLOs of your model.

To learn more about the various XProf tools, check out the XProf documentation

Demo

First time user? Come and check out this Colab Demo.

Quick Start

Prerequisites

  • xprof >= 2.20.0
  • (optional) TensorBoard >= 2.20.0

Note: XProf requires access to the Internet to load the Google Chart library. Some charts and tables may be missing if you run XProf entirely offline on your local machine, behind a corporate firewall, or in a datacenter.

If you use Google Cloud to run your workloads, we recommend the xprofiler tool. It provides a streamlined profile collection and viewing experience using VMs running XProf.

Installation

To get the most recent release version of XProf, install it via pip:

$ pip install xprof

or with TensorBoard:

$ pip install xprof tensorboard

Note: For Python 3.12+ users, if you encounter ModuleNotFoundError: No module named 'pkg_resources', install an older version of setuptools:

pip install "setuptools<70"

Running XProf

XProf can be launched as a standalone server or used as a plugin within TensorBoard. For large-scale use, it can be deployed in a distributed mode with separate aggregator and worker instances (more details on it later in the doc).

Command-Line Arguments

When launching XProf from the command line, you can use the following arguments:

  • logdir (optional): The directory containing XProf profile data (files ending in .xplane.pb). This can be provided as a positional argument or with -l or --logdir. If provided, XProf will load and display profiles from this directory. If omitted, XProf will start without loading any profiles, and you can dynamically load profiles using session_path or run_path URL parameters, as described in the Log Directory Structure section.
  • -p <port>, --port <port>: The port for the XProf web server. Defaults to 8791.
  • -gp <grpc_port>, --grpc_port <grpc_port>: The port for the gRPC server used for distributed processing. Defaults to 50051. This must be different from --port.
  • -wsa <addresses>, --worker_service_address <addresses>: A comma-separated list of worker addresses (e.g., host1:50051,host2:50051) for distributed processing. Defaults to to 0.0.0.0:<grpc_port>.
  • -hcpb, --hide_capture_profile_button: If set, hides the 'Capture Profile' button in the UI.

Standalone

If you have profile data in a directory (e.g., profiler/demo), you can view it by running:

$ xprof profiler/demo --port=6006

Or with the optional flag:

$ xprof --logdir=profiler/demo --port=6006

With TensorBoard

If you have TensorBoard installed, you can run:

$ tensorboard --logdir=profiler/demo

If you are behind a corporate firewall, you may need to include the --bind_all tensorboard flag.

Go to localhost:6006/#profile of your browser, you should now see the demo overview page show up. Congratulations! You're now ready to capture a profile.

Log Directory Structure

When using XProf, profile data must be placed in a specific directory structure. XProf expects .xplane.pb files to be in the following path:

<log_dir>/plugins/profile/<session_name>/
  • <log_dir>: This is the root directory that you supply to tensorboard --logdir.
  • plugins/profile/: This is a required subdirectory.
  • <session_name>/: Each subdirectory inside plugins/profile/ represents a single profiling session. The name of this directory will appear in the TensorBoard UI dropdown to select the session.

Example:

If your log directory is structured like this:

/path/to/your/log_dir/
└── plugins/
    └── profile/
        ├── my_experiment_run_1/
        │   └── host0.xplane.pb
        └── benchmark_20251107/
            └── host1.xplane.pb

You would launch TensorBoard with:

tensorboard --logdir /path/to/your/log_dir/

The runs my_experiment_run_1 and benchmark_20251107 will be available in the "Sessions" tab of the UI.

You can also dynamically load sessions from a GCS bucket or local filesystem by passing URL parameters when loading XProf in your browser. This method works whether or not you provided a logdir at startup and is useful for viewing profiles from various locations without restarting XProf.

For example, if you start XProf with no log directory:

xprof

You can load sessions using the following URL parameters.

Assume you have profile data stored on GCS or locally, structured like this:

gs://your-bucket/profile_runs/
├── my_experiment_run_1/
│   ├── host0.xplane.pb
│   └── host1.xplane.pb
└── benchmark_20251107/
    └── host0.xplane.pb

There are two URL parameters you can use:

  • session_path: Use this to load a single session directly. The path should point to a directory containing .xplane.pb files for one session.

    • GCS Example: http://localhost:8791/?session_path=gs://your-bucket/profile_runs/my_experiment_run_1
    • Local Path Example: http://localhost:8791/?session_path=/path/to/profile_runs/my_experiment_run_1
    • Result: XProf will load the my_experiment_run_1 session, and you will see its data in the UI.
  • run_path: Use this to point to a directory that contains multiple session directories.

    • GCS Example: http://localhost:8791/?run_path=gs://your-bucket/profile_runs/
    • Local Path Example: http://localhost:8791/?run_path=/path/to/profile_runs/
    • Result: XProf will list all session directories found under run_path (i.e., my_experiment_run_1 and benchmark_20251107) in the "Sessions" dropdown in the UI, allowing you to switch between them.

Loading Precedence

If multiple sources are provided, XProf uses the following order of precedence to determine which profiles to load:

  1. session_path URL parameter
  2. run_path URL parameter
  3. logdir command-line argument

Distributed Profiling

XProf supports distributed profile processing by using an aggregator that distributes work to multiple XProf workers. This is useful for processing large profiles or handling multiple users.

Note: Currently, distributed processing only benefits the following tools: overview_page, framework_op_stats, input_pipeline, and pod_viewer.

Note: The ports used in these examples (6006 for the aggregator HTTP server, 9999 for the worker HTTP server, and 50051 for the worker gRPC server) are suggestions and can be customized.

Worker Node

Each worker node should run XProf with a gRPC port exposed so it can receive processing requests. You should also hide the capture button as workers are not meant to be interacted with directly.

$ xprof --grpc_port=50051 --port=9999 --hide_capture_profile_button

Aggregator Node

The aggregator node runs XProf with the --worker_service_address flag pointing to all available workers. Users will interact with aggregator node's UI.

$ xprof --worker_service_address=<worker1_ip>:50051,<worker2_ip>:50051 --port=6006 --logdir=profiler/demo

Replace <worker1_ip>, <worker2_ip> with the addresses of your worker machines. Requests sent to the aggregator on port 6006 will be distributed among the workers for processing.

For deploying a distributed XProf setup in a Kubernetes environment, see Kubernetes Deployment Guide.

Nightlies

Every night, a nightly version of the package is released under the name of xprof-nightly. This package contains the latest changes made by the XProf developers.

To install the nightly version of profiler:

$ pip uninstall xprof tensorboard-plugin-profile
$ pip install xprof-nightly

Building from source

If the pip packages don't work for you, you can build XProf from source using Bazel.

1. Set up Bazel

Bazel is the build system used for XProf. Bazelisk is a wrapper for Bazel that simplifies Bazel version management. Download the appropriate .deb package for your system from the Bazelisk releases page and install the downloaded package:

sudo apt install ~/Downloads/bazelisk-amd64.deb

2. Obtain the Repository

Clone the XProf GitHub repository to your local machine:

git clone https://github.com/openxla/xprof.git
cd xprof

3. Build the Project

Build the pip Package: Use Bazel to build the XProf pip package:

bazel run --config=public_cache plugin:build_pip_package

Navigate to the Bazel Output Directory and install:

cd /tmp/profile-pip
pip install .

Next Steps

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

xprof_nightly-2.23.1a20260408-cp313-abi3-win_amd64.whl (21.8 MB view details)

Uploaded CPython 3.13+Windows x86-64

xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_35_aarch64.whl (42.1 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.35+ ARM64

xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_27_x86_64.whl (24.8 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.27+ x86-64

xprof_nightly-2.23.1a20260408-cp312-abi3-win_amd64.whl (21.8 MB view details)

Uploaded CPython 3.12+Windows x86-64

xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_35_aarch64.whl (42.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.35+ ARM64

xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_27_x86_64.whl (24.8 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64

xprof_nightly-2.23.1a20260408-cp311-abi3-win_amd64.whl (21.8 MB view details)

Uploaded CPython 3.11+Windows x86-64

xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_35_aarch64.whl (42.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.35+ ARM64

xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_27_x86_64.whl (24.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.27+ x86-64

xprof_nightly-2.23.1a20260408-cp310-abi3-win_amd64.whl (21.8 MB view details)

Uploaded CPython 3.10+Windows x86-64

xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_35_aarch64.whl (42.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.35+ ARM64

xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_27_x86_64.whl (24.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.27+ x86-64

File details

Details for the file xprof_nightly-2.23.1a20260408-cp313-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 725ceadd756097269a47d1a6b8cd4bde924df22a7afc69a88ef2e9da1cb69ac5
MD5 6cfc761ed74ec8f749e71a15e8b0ada5
BLAKE2b-256 b67573c175cabcce1b22055fe82e3d8627fd7f10be734e90004736fca894c135

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 307a833a1d838fefa0ca1b6e5287a8e7408fd202a3c2aa461e0f0bae487f65b5
MD5 ca1160762af5d14a001507c5c09a6b5a
BLAKE2b-256 8498067cf2158c23bf26f9318bcb7837e8093cda74dca0355f7dcc4e268b7c7d

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp313-abi3-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 b36853e6bee998ed6667f240dc1e964b54cc75eae21ccb5a990042f2a1faae66
MD5 e2777e21218c89ac4bac6568071b709e
BLAKE2b-256 f408ef4820f11ab92e64304a68081ff7420dafcfbafb9a8bf4068b69a50c86f5

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp312-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fb3954eafd3544d8206fc4e3d2ea8e68360217936b0631a2e220612f26b75416
MD5 a6ad34df3b0a70fd5e2947787e35512c
BLAKE2b-256 62a28187e6cb32cbbbb292e38c9e78edf9e4fac0105eea88b1a6c4a29042c197

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 1098f5215560f6a62a305044cb9a69e53adadee82594018f367d81cda6d34295
MD5 389de1264e4bd6142813d3a886b119f2
BLAKE2b-256 2a0f79af8712238824697e3b3efc42d1bacd23ff3a7633a49edb53138def31bb

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp312-abi3-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 225db7bd832370ff9ddb23455ac6e580878c36ee07222730cfcf7b6d4f984dbe
MD5 a258d3c19249268de1958e51b0a2380d
BLAKE2b-256 944a862620274dc8b9f391871988e6cbeaed0303dca4d64f1d2d056f59b45b2b

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ad9be05e4c035bf3d1770cabdcae666e10662738bb19ac4b2cbf0d2399927d52
MD5 cd92c22b902adb2506d24144d18c326c
BLAKE2b-256 000f65951aa39b8cca1f2c5d5d12b979b4849d3569df58537fd7bed565be3897

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 cb35a19bd704ed45813092d1196e496b18e2f1bbefeb17ab7fd233dbd8d08821
MD5 ae854ff83332ec925f0172f88ffbc1aa
BLAKE2b-256 2c1424d433be5971e14ec40b16a1b09abf52c4e57cea22d6a92b15276f237a31

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp311-abi3-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 24582484dc4db4bebdf8de7904583115739a657072576bfe0d25a86d21bbd1a0
MD5 6a57cc9434369e58f5d93ae1afe545fd
BLAKE2b-256 3bce59f5a777e8f606dd9fa72171772aa429511b6799124c8d60ca7917caa579

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 05db3114169919b332de112c6344f02b42d492ef81bcfde270803584146ee864
MD5 a90c009de7320b1151f59c80d4aff490
BLAKE2b-256 99d78a4b564410229906c6b667aef5f4820df9108e162998633ea49d1033906a

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 9649717041fd1ea20d5f9022f5da63219d4f61bdf9e45bab53206c27ad20e7d6
MD5 0cbd9ee7c2e0614ea69037b6fc4bda86
BLAKE2b-256 9dae5a28e4870fbe727ae49ef4495c6937cea2940c732f0014fa4d6c2052dfe0

See more details on using hashes here.

File details

Details for the file xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof_nightly-2.23.1a20260408-cp310-abi3-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 751056ce9e3b8c97cb754c36fc9ca7d424cbe01c4e4fb1d94084c7125eba413b
MD5 e87856bec8beb1194fe8051f91e2bb55
BLAKE2b-256 e64ccf35f4a43dd3f693681dd5ad13b958c1bd3400de32b2897537bbd93a1188

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