You don't have to use raw torch.profiler at all. There is a whole page in Lightning Docs dedicated to Profiling ..

.. and its as easy as passing a trainer flag called profiler like

# other profilers are "simple", "advanced" etc
trainer = pl.Trainer(profiler="pytorch")

Also, set TensorBoardLogger as your preferred logger as you normally do

trainer = pl.Trainer(profiler="pytorch", logger=TensorBoardLogger(..))
Answer from ayandas on Stack Overflow
🌐
PyTorch
docs.pytorch.org › ecosystem › pytorch profiler with tensorboard
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.12.0+cu130 documentation
July 20, 2022 - This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
DeepSpeed
deepspeed.ai › home › tutorials
Using PyTorch Profiler with DeepSpeed for performance debugging - DeepSpeed
1 week ago - PyTorch Profiler is an open-source tool that enables accurate and efficient performance analysis and troubleshooting for large-scale deep learning models. The profiling results can be outputted as a .json trace file and viewed in Google’s Perfetto trace viewer (https://ui.perfetto.dev).
🌐
PyTorch
docs.pytorch.org › ecosystem › pytorch profiler with tensorboard
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.10.0+cu128 documentation
July 20, 2022 - This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
PyTorch
pytorch.org › blog › introducing-pytorch-profiler-the-new-and-improved-performance-tool
Introducing PyTorch Profiler – the new and improved performance tool – PyTorch
March 25, 2021 - This new profiler collects both GPU hardware and PyTorch related information, correlates them, performs automatic detection of bottlenecks in the model, and generates recommendations on how to resolve these bottlenecks. All of this information from the profiler is visualized for the user in ...
🌐
Habana
docs.habana.ai › en › latest › Profiling › Profiling_with_PyTorch.html
Profiling with PyTorch — Gaudi Documentation 1.23.0 documentation
Additionally, it provides guidelines on how to use TensorBoard to view Intel® Gaudi® AI accelerator specific information for performance profiling. These capabilities are enabled using the torch-tb-profiler TensorBoard plugin which is included in the Intel Gaudi PyTorch package.
Find elsewhere
🌐
PyTorch
docs.pytorch.org › reference api › torch.profiler
torch.profiler — PyTorch main documentation
Outputs tracing files to directory of dir_name, then that directory can be directly delivered to tensorboard as logdir. worker_name should be unique for each worker in distributed scenario, it will be set to ‘[hostname]_[pid]’ by default. ...
🌐
PyPI
pypi.org › project › torch-tb-profiler
torch-tb-profiler · PyPI
PyTorch Profiler TensorBoard Plugin : https://github.com/pytorch/kineto/tree/main/tb_plugin · These details have been verified by PyPI · aaronenyeshi chauhang seemethere TorchTBProfiler · These details have not been verified by PyPI · Homepage · License: BSD License (BSD-3) Author: PyTorch Team ·
      » pip install torch-tb-profiler
    
Published   Oct 06, 2023
Version   0.4.3
🌐
PyTorch
docs.pytorch.org › ecosystem › pytorch profiler with tensorboard
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.9.0+cu128 documentation
July 20, 2022 - This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
PyTorch
docs.pytorch.org › ecosystem › pytorch profiler with tensorboard
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.8.0+cu128 documentation
July 20, 2022 - This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
Pytorch-cn
pytorch-cn.com › tutorials › intermediate › tensorboard_profiler_tutorial.html
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.5.0+cu124 documentation
This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
PyTorch
docs.pytorch.org › ecosystem › pytorch profiler with tensorboard
PyTorch Profiler With TensorBoard — PyTorch Tutorials 2.7.0+cu126 documentation
July 20, 2022 - This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
APXML
apxml.com › courses › pytorch-for-tensorflow-developers › chapter-6-advanced-pytorch-features-tf-users › profiling-pytorch-code
PyTorch Profiler | Performance Optimization Guide
# ... (model and inputs setup) from torch.profiler import profile, schedule, ProfilerActivity, tensorboard_trace_handler # Ensure the log directory exists log_dir = "tb_logs/my_model_profile" import os os.makedirs(log_dir, exist_ok=True) # Using a schedule for targeted profiling my_schedule = schedule(wait=1, warmup=1, active=2, repeat=1) with profile( activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA], schedule=my_schedule, on_trace_ready=tensorboard_trace_handler(log_dir), record_shapes=True, with_stack=True ) as prof_tb: for step in range(10): # Simulating training steps model(inputs) prof_tb.step() # Important: Signal the profiler that a step is complete # After running, launch TensorBoard: tensorboard --logdir tb_logs · Then, launch TensorBoard (tensorboard --logdir tb_logs) and navigate to the "PyTorch Profiler" tab.
🌐
Google Cloud
cloud.google.com › cloud tpu › profile pytorch xla workloads
Profile PyTorch XLA workloads | Cloud TPU | Google Cloud Documentation
View the Profile. Open the URL provided by TensorBoard in your web browser (usually http://localhost:6006). Navigate to the PyTorch XLA - Profile tab to view the interactive trace.
🌐
Medium
medium.com › data-science › solving-bottlenecks-on-the-data-input-pipeline-with-pytorch-profiler-and-tensorboard-5dced134dbe9
Solving Bottlenecks on the Data Input Pipeline with PyTorch Profiler and TensorBoard | by Chaim Rand | TDS Archive | Medium
August 30, 2023 - In the following sections we will use PyTorch Profiler and its associated TensorBoard plugin in order to assess the performance of our model. Our focus will be on the Trace View of the profiler report.
🌐
Windows
torchtutorialstaging.z5.web.core.windows.net › intermediate › tensorboard_profiler_tutorial.html
PyTorch Profiler With TensorBoard — PyTorch Tutorials 1.8.1+cu102 documentation
This tutorial demonstrates how to use TensorBoard plugin with PyTorch Profiler to detect performance bottlenecks of the model.
🌐
Towards Data Science
towardsdatascience.com › home › latest › solving bottlenecks on the data input pipeline with pytorch profiler and tensorboard
Solving Bottlenecks on the Data Input Pipeline with PyTorch Profiler and TensorBoard | Towards Data Science
January 23, 2025 - In the following sections we will use PyTorch Profiler and its associated TensorBoard plugin in order to assess the performance of our model. Our focus will be on the Trace View of the profiler report.