XProf Profiler Plugin
Project description
[!IMPORTANT] XProf is hiring! Apply now at https://g.co/jobs/xprof
XProf (+ Tensorboard Profiler Plugin)
An open, scalable, and extensible profiler for the modern ML stack.
About ✧ Installation ✧ Usage ✧ Resources
About
XProf offers a number of tools to analyse and visualize the performance of your model across multiple devices. Some of the tools include:
Overview PageA high-level overview of the performance of your model. This is an aggregated overview for your host and all devices. It includes:
|
Trace ViewerDisplays a timeline of the execution of your model that shows:
|
Memory ProfileMonitors the memory usage of your model. |
Graph ViewerA visualization of the graph structure of HLOs of your model. |
To learn more about the various XProf tools, check out the XProf documentation
[!TIP] New to profiling? Come and check out this Colab Demo.
Installation
To get the most recent release version of XProf, install it via pip:
$ pip install xprof
[!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"
Alternative installation options:
Installation with Tensorboard
$ pip install xprof tensorboard
Google Cloud
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.
Nightly Releases
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
Build from Source
If the pip packages don't work, 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 .
Usage
[!IMPORTANT] 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.
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.
Command-Line Arguments
When launching XProf from the command line, you can use the following arguments:
| Command | Shorthand | Default | Description |
|---|---|---|---|
--logdir <path> |
-l <path> |
The directory containing XProf profile data (files ending in .xplane.pb). If provided, XProf will load and display profiles from this directory. If omitted, XProf will start without loading any profiles.1 | |
--port <port> |
-p <port> |
8791 |
The port for the XProf web server. |
--grpc_port <port> |
-gp <port> |
50051 |
The port for the gRPC server used for distributed processing. This must be different from --port. |
--worker_service_address <addresses> |
-wsa <addresses> |
0.0.0.0:<grpc_port> |
A comma-separated list of worker addresses (e.g., host1:50051,host2:50051) for distributed processing. |
--hide_capture_profile_button |
-hcpb |
N/A | If set, hides the 'Capture Profile' button in the UI. |
1 You can dynamically load profiles using session_path or run_path URL parameters, as described in the Log Directory Structure section.
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 totensorboard --logdir.plugins/profile/: This is a required subdirectory.<session_name>/: Each subdirectory insideplugins/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.pbfiles 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_1session, and you will see its data in the UI.
- GCS Example:
-
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_1andbenchmark_20251107) in the "Sessions" dropdown in the UI, allowing you to switch between them.
- GCS Example:
Loading Precedence
If multiple sources are provided, XProf uses the following order of precedence to determine which profiles to load:
session_pathURL parameterrun_pathURL parameterlogdircommand-line argument
Distributed Profiling
[!WARNING] Currently, distributed processing only benefits the following tools:
overview_page,framework_op_stats,input_pipeline, andpod_viewer.
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] The ports used in these examples (
6006for the aggregator HTTP server,9999for the worker HTTP server, and50051for 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.
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tbp_nightly-2.23.3a20260522-py3-none-win_amd64.whl.
File metadata
- Download URL: tbp_nightly-2.23.3a20260522-py3-none-win_amd64.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cdbc7295fb1d1c15ee375fef1e54c6dd716fcc35e8a8aefcba391c842c7f847
|
|
| MD5 |
6cd40356d2f2a69896a8eea2507f6b16
|
|
| BLAKE2b-256 |
206051b1e310f09d55336c6f66468e89ffe466df7bd05c6ad078c04284613960
|