tf.profiler.experimental.client.trace
Stay organized with collections
Save and categorize content based on your preferences.
Sends gRPC requests to one or more profiler servers to perform on-demand profiling.
tf.profiler.experimental.client.trace(
service_addr,
logdir,
duration_ms,
worker_list='',
num_tracing_attempts=3,
options=None
)
This method will block the calling thread until it receives responses from all
servers or until deadline expiration. Both single host and multiple host
profiling are supported on CPU, GPU, and TPU.
The profiled results will be saved by each server to the specified TensorBoard
log directory (i.e. the directory you save your model checkpoints). Use the
TensorBoard profile plugin to view the visualization and analysis results.
Args |
service_addr
|
A comma delimited string of gRPC addresses of the workers to
profile.
e.g. service_addr='grpc://localhost:6009'
service_addr='grpc://10.0.0.2:8466,grpc://10.0.0.3:8466'
service_addr='grpc://localhost:12345,grpc://localhost:23456'
|
logdir
|
Path to save profile data to, typically a TensorBoard log directory.
This path must be accessible to both the client and server.
e.g. logdir='gs://your_tb_dir'
|
duration_ms
|
Duration of tracing or monitoring in milliseconds. Must be
greater than zero.
|
worker_list
|
An optional TPU only configuration. The list of workers to
profile in the current session.
|
num_tracing_attempts
|
Optional. Automatically retry N times when no trace
event is collected (default 3).
|
options
|
profiler.experimental.ProfilerOptions namedtuple for miscellaneous
profiler options.
|
Raises |
InvalidArgumentError
|
For when arguments fail validation checks.
|
UnavailableError
|
If no trace event was collected.
|
Example usage (CPU/GPU):
# Start a profiler server before your model runs.
tf.profiler.experimental.server.start(6009)
# (Model code goes here).
# Send gRPC request to the profiler server to collect a trace of your model.
tf.profiler.experimental.client.trace('grpc://localhost:6009',
'/nfs/tb_log', 2000)
Example usage (Multiple GPUs):
# E.g. your worker IP addresses are 10.0.0.2, 10.0.0.3, 10.0.0.4, and you
# would like to schedule start of profiling 1 second from now, for a
# duration of 2 seconds.
options['delay_ms'] = 1000
tf.profiler.experimental.client.trace(
'grpc://10.0.0.2:8466,grpc://10.0.0.3:8466,grpc://10.0.0.4:8466',
'gs://your_tb_dir',
2000,
options=options)
Example usage (TPU):
# Send gRPC request to a TPU worker to collect a trace of your model. A
# profiler service has been started in the TPU worker at port 8466.
# E.g. your TPU IP address is 10.0.0.2 and you want to profile for 2 seconds
# .
tf.profiler.experimental.client.trace('grpc://10.0.0.2:8466',
'gs://your_tb_dir', 2000)
Example usage (Multiple TPUs):
# Send gRPC request to a TPU pod to collect a trace of your model on
# multiple TPUs. A profiler service has been started in all the TPU workers
# at the port 8466.
# E.g. your TPU IP addresses are 10.0.0.2, 10.0.0.3, 10.0.0.4, and you want
# to profile for 2 seconds.
tf.profiler.experimental.client.trace(
'grpc://10.0.0.2:8466',
'gs://your_tb_dir',
2000,
'10.0.0.2:8466,10.0.0.3:8466,10.0.0.4:8466')
Launch TensorBoard and point it to the same logdir you provided to this API.
# logdir can be gs://your_tb_dir as in the above examples.
$ tensorboard --logdir=/tmp/tb_log
Open your browser and go to localhost:6006/#profile to view profiling results.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[],[],null,["# tf.profiler.experimental.client.trace\n\n|---------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/profiler/profiler_client.py#L25-L131) |\n\nSends gRPC requests to one or more profiler servers to perform on-demand profiling. \n\n tf.profiler.experimental.client.trace(\n service_addr,\n logdir,\n duration_ms,\n worker_list='',\n num_tracing_attempts=3,\n options=None\n )\n\nThis method will block the calling thread until it receives responses from all\nservers or until deadline expiration. Both single host and multiple host\nprofiling are supported on CPU, GPU, and TPU.\nThe profiled results will be saved by each server to the specified TensorBoard\nlog directory (i.e. the directory you save your model checkpoints). Use the\nTensorBoard profile plugin to view the visualization and analysis results.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `service_addr` | A comma delimited string of gRPC addresses of the workers to profile. e.g. service_addr='grpc://localhost:6009' service_addr='grpc://10.0.0.2:8466,grpc://10.0.0.3:8466' service_addr='grpc://localhost:12345,grpc://localhost:23456' |\n| `logdir` | Path to save profile data to, typically a TensorBoard log directory. This path must be accessible to both the client and server. e.g. logdir='gs://your_tb_dir' |\n| `duration_ms` | Duration of tracing or monitoring in milliseconds. Must be greater than zero. |\n| `worker_list` | An optional TPU only configuration. The list of workers to profile in the current session. |\n| `num_tracing_attempts` | Optional. Automatically retry N times when no trace event is collected (default 3). |\n| `options` | profiler.experimental.ProfilerOptions namedtuple for miscellaneous profiler options. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------------------|--------------------------------------------|\n| `InvalidArgumentError` | For when arguments fail validation checks. |\n| `UnavailableError` | If no trace event was collected. |\n\n\u003cbr /\u003e\n\nExample usage (CPU/GPU): \n\n # Start a profiler server before your model runs.\n tf.profiler.experimental.server.start(6009)\n # (Model code goes here).\n # Send gRPC request to the profiler server to collect a trace of your model.\n tf.profiler.experimental.client.trace('grpc://localhost:6009',\n '/nfs/tb_log', 2000)\n\nExample usage (Multiple GPUs): \n\n # E.g. your worker IP addresses are 10.0.0.2, 10.0.0.3, 10.0.0.4, and you\n # would like to schedule start of profiling 1 second from now, for a\n # duration of 2 seconds.\n options['delay_ms'] = 1000\n tf.profiler.experimental.client.trace(\n 'grpc://10.0.0.2:8466,grpc://10.0.0.3:8466,grpc://10.0.0.4:8466',\n 'gs://your_tb_dir',\n 2000,\n options=options)\n\nExample usage (TPU): \n\n # Send gRPC request to a TPU worker to collect a trace of your model. A\n # profiler service has been started in the TPU worker at port 8466.\n # E.g. your TPU IP address is 10.0.0.2 and you want to profile for 2 seconds\n # .\n tf.profiler.experimental.client.trace('grpc://10.0.0.2:8466',\n 'gs://your_tb_dir', 2000)\n\nExample usage (Multiple TPUs): \n\n # Send gRPC request to a TPU pod to collect a trace of your model on\n # multiple TPUs. A profiler service has been started in all the TPU workers\n # at the port 8466.\n # E.g. your TPU IP addresses are 10.0.0.2, 10.0.0.3, 10.0.0.4, and you want\n # to profile for 2 seconds.\n tf.profiler.experimental.client.trace(\n 'grpc://10.0.0.2:8466',\n 'gs://your_tb_dir',\n 2000,\n '10.0.0.2:8466,10.0.0.3:8466,10.0.0.4:8466')\n\nLaunch TensorBoard and point it to the same logdir you provided to this API. \n\n # logdir can be gs://your_tb_dir as in the above examples.\n $ tensorboard --logdir=/tmp/tb_log\n\nOpen your browser and go to localhost:6006/#profile to view profiling results."]]