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.6-cp313-none-manylinux_2_35_aarch64.whl (23.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.35+ ARM64

xprof-2.21.6-cp313-none-manylinux_2_27_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64

xprof-2.21.6-cp313-none-any.whl (19.2 MB view details)

Uploaded CPython 3.13

xprof-2.21.6-cp312-none-manylinux_2_35_aarch64.whl (23.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ ARM64

xprof-2.21.6-cp312-none-manylinux_2_27_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64

xprof-2.21.6-cp312-none-any.whl (19.2 MB view details)

Uploaded CPython 3.12

xprof-2.21.6-cp311-none-manylinux_2_35_aarch64.whl (23.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.35+ ARM64

xprof-2.21.6-cp311-none-manylinux_2_27_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64

xprof-2.21.6-cp311-none-any.whl (19.2 MB view details)

Uploaded CPython 3.11

xprof-2.21.6-cp310-none-manylinux_2_35_aarch64.whl (23.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.35+ ARM64

xprof-2.21.6-cp310-none-manylinux_2_27_x86_64.whl (22.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64

xprof-2.21.6-cp310-none-any.whl (20.4 MB view details)

Uploaded CPython 3.10

File details

Details for the file xprof-2.21.6-cp313-none-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp313-none-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 781351ca75ba84fe9226f92d92c9fb265ab5be727564f9f0e0bac33c200ec653
MD5 9180782a30c6d7ec1868aa8eb4c670b5
BLAKE2b-256 c128ef4ef3291e22bf1054cb0ea85e2b88bf370d7eaa30f4fa6f0188965d5c76

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp313-none-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp313-none-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 f24526cd39206941fcb1fd0e70414a7e31be227706921291e419f75d2019aa27
MD5 b2366f85bde142c303e3060ea6a35e75
BLAKE2b-256 14ef1ba951d52d1e48dc80e4c49ad70082c721cdc3400d69741268fe3163943c

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp313-none-any.whl.

File metadata

  • Download URL: xprof-2.21.6-cp313-none-any.whl
  • Upload date:
  • Size: 19.2 MB
  • Tags: CPython 3.13
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for xprof-2.21.6-cp313-none-any.whl
Algorithm Hash digest
SHA256 068697deda0b30ba41e75553197905bcc43d2e81850c2db21fe9b011d908d600
MD5 c90a060fe71ccf77e35f241e1bed6127
BLAKE2b-256 657b21e7852f0783339df7842a3181bfe8ef317608a19a5c6daf6a75e12815c8

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp312-none-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp312-none-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 aa5ab88a88b8d70632b59a4c7a4a5024d11ed4cc34e75c12ade69f453d5d4a46
MD5 a1bd1d5f780b5f2aacd919b7d53fa63a
BLAKE2b-256 32daa88841648e04fb2bf0c7da70f0dd222a9f8710c9516c43105a7ea5213d04

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp312-none-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp312-none-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 37a66b7b38b99a65a7c816cb6f7118f6261cb3ad7850e14c14656765d8b70afb
MD5 3e57f50cb7fb27118c670136ca13b60f
BLAKE2b-256 d90066a81559c6db6442e986afbd1bc50efbb52c166e9d4432dee2f28b0d0fe8

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp312-none-any.whl.

File metadata

  • Download URL: xprof-2.21.6-cp312-none-any.whl
  • Upload date:
  • Size: 19.2 MB
  • Tags: CPython 3.12
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for xprof-2.21.6-cp312-none-any.whl
Algorithm Hash digest
SHA256 71aeb20edd72624dac1234d45b20e4bdbdecbdff8bee361c37e50c2cc41a5f94
MD5 838f63675a46af37c4111c0f6466162a
BLAKE2b-256 e376051aa3498dc6d9f0d34a09a8e09a7461649f864d87c7b4a90109f520375d

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp311-none-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp311-none-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 58b4873d5a373f9d88d11e7151d381329b25626e0a60c6f11e66ab61076db30e
MD5 841509727be1c3a876e67737856270a5
BLAKE2b-256 e1a5c80bf771bce071cf112fbbb37cf737caa6789d74d95a02fd569599cbb98d

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp311-none-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp311-none-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 80a5e69ed2217124a35be111742e7379a85e5c4a9dce4837166527655bfdfdc9
MD5 dd4f309c699a4a6204a962207dbda209
BLAKE2b-256 d441edc46056dd6e25fd8d1042c9f543228d5920dee1aca482d883b2ef7d3b97

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp311-none-any.whl.

File metadata

  • Download URL: xprof-2.21.6-cp311-none-any.whl
  • Upload date:
  • Size: 19.2 MB
  • Tags: CPython 3.11
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for xprof-2.21.6-cp311-none-any.whl
Algorithm Hash digest
SHA256 f28aff36688e247dac1960002b50664835d0e5591166d2fd376dbfd4e6f6c528
MD5 0f21e5fe559d055637af14225ff1f982
BLAKE2b-256 ba40c63173557a4ee32205dba0019fe4463cc13da43b5035c454a5d4716ff89a

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp310-none-manylinux_2_35_aarch64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp310-none-manylinux_2_35_aarch64.whl
Algorithm Hash digest
SHA256 867d31c79b38d667f090be1d8a6163da711b9c1d010c759cd6b6e0af42141fff
MD5 988a845e949c18ba3766089c5602cece
BLAKE2b-256 31eb86f47c01dc37080fbdbc215231563cb61e0ce7e76372614be6c4b465c9f6

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp310-none-manylinux_2_27_x86_64.whl.

File metadata

File hashes

Hashes for xprof-2.21.6-cp310-none-manylinux_2_27_x86_64.whl
Algorithm Hash digest
SHA256 1f2e6078b0fb54fca80f6bf4d2fd522bfff7d5d9db2833f03eca14616e68f68a
MD5 2cc8a9146cd0533b7d22b857d9629f09
BLAKE2b-256 0618cd5e22dfdd2e4da1137f5f7500949c6134de6e1939b42b0f5d412081e183

See more details on using hashes here.

File details

Details for the file xprof-2.21.6-cp310-none-any.whl.

File metadata

  • Download URL: xprof-2.21.6-cp310-none-any.whl
  • Upload date:
  • Size: 20.4 MB
  • Tags: CPython 3.10
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.12

File hashes

Hashes for xprof-2.21.6-cp310-none-any.whl
Algorithm Hash digest
SHA256 76f73bf352513dca95005bc4785bbcc8e67c8c393035b21f1513a18ed1827c54
MD5 43be1a6348fd42d2d363f4a81535a087
BLAKE2b-256 ec73a4d1cf4e2f7cad108ee520a9f57c9287078e60fd496d4276e02b9e0b2340

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