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

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

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-2.21.4-cp313-none-manylinux2014_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.13

xprof-2.21.4-cp313-none-macosx_12_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.13macOS 12.0+ ARM64

xprof-2.21.4-cp312-none-manylinux2014_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.12

xprof-2.21.4-cp312-none-macosx_12_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.12macOS 12.0+ ARM64

xprof-2.21.4-cp311-none-manylinux2014_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.11

xprof-2.21.4-cp311-none-macosx_12_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.11macOS 12.0+ ARM64

xprof-2.21.4-cp310-none-manylinux2014_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.10

xprof-2.21.4-cp310-none-macosx_12_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.10macOS 12.0+ ARM64

xprof-2.21.4-cp39-none-manylinux2014_x86_64.whl (21.4 MB view details)

Uploaded CPython 3.9

xprof-2.21.4-cp39-none-macosx_12_0_arm64.whl (19.3 MB view details)

Uploaded CPython 3.9macOS 12.0+ ARM64

File details

Details for the file xprof-2.21.4-cp313-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp313-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfb3a5a31a1f08941b721f45b5c55a20a6d3915c0958af501d2f659f7fd2467d
MD5 2940aae2e8adc5bf8e0de1d1ec537975
BLAKE2b-256 21d94e67f3a9290ffd7b8f36c7d6330b05f7c28643ae91d1b6e79ff4ea78a426

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp313-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp313-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a6b1987b650916e05b0fe815fd464ae40ac44670ef84736a1b4ea321a09ae4fb
MD5 cd77b1d648e2c02b5d91653148b7a0f2
BLAKE2b-256 af3095fbee693e9706cad0ea1c5bb4b7efdf18016c46900d41ab716faf0ed02d

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp312-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp312-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 074dc945d96816737f79543986781cb698e0cb3d042e2a00f3dfa47c936415e1
MD5 a6b8d8ea784bfc61e206b7368fe31ba6
BLAKE2b-256 ba05c74bf35b58dbb064a9b9613951f2c26e51d2178f673ac1b721229a7932af

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp312-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp312-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 e7a6558f48b687ba19fb164a85be38c3f058389b9383cfa587d4220e23752fdc
MD5 df6390e278bec043763a7af212a8b7f9
BLAKE2b-256 2ab34b472f4ae9781fa693fdc9cb5a47e365f909ee558b835eeea4b70a74d0dc

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp311-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp311-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9e86d290077e7f3cf2c25cd23db2da0fb3836a53c5c472c102efe9a611c291c4
MD5 4f238336f5e59ff1f7847959f6e240ed
BLAKE2b-256 95aa9b12df921b73f8cbfd42b3eeaa46e251791f9f426dbe111b389068857998

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp311-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp311-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 a0afba62772855fc3b4491a7bedb7e92e4d49c37d088a832dd8eac0c5c98b47d
MD5 16b3191fc884789cd8a548390c07c1a3
BLAKE2b-256 2d3a7d36fca8954bdee7293b880143cb35ec020b3b471981f7124d7061e94782

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp310-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp310-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 026496f29762916b7e22c4053624f754b5f8466d4d649c0c34c40902318c87ca
MD5 923be07d42ed50ede16f533cb787d7ce
BLAKE2b-256 c27e5e04249a43c501779cd897d1166b2c6f12acbafd7bdf7f911d8539a0f26e

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp310-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp310-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 09e0ad072cc0fe608337defb1753404e27735f43b8e50f96023cf8e8d34cad14
MD5 28a411d960ac39b02a6232010d7b2e31
BLAKE2b-256 7c3ee80a3747e1b3fe0ab7513e27c16e0cbf52cc8c5d4d5003b5fb7481fd0b57

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp39-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp39-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a5c4bd9af3dfd4a7d3424390f64d92b197652e31507fc3d8cbbae542262c8ec6
MD5 58324a5f8cb3b4bf4c8de64c582061d2
BLAKE2b-256 671dba01fb796cdd4906760bf2cba1704432b8d6cae6a9cf1e775210d6c7755c

See more details on using hashes here.

File details

Details for the file xprof-2.21.4-cp39-none-macosx_12_0_arm64.whl.

File metadata

File hashes

Hashes for xprof-2.21.4-cp39-none-macosx_12_0_arm64.whl
Algorithm Hash digest
SHA256 d5bfa2b63a0ba52640fd9ac11131f836ec42969e041ed36ab2f17ad4ae639ea3
MD5 66d240a8ecf063199c44dc299ebb778e
BLAKE2b-256 bb79ab2863eefc98665c9f9ada7df4988e694235e9f3597c7d8d798e2a65849a

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