You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source-pytorch/tuning/profiler_basic.rst
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,3 +121,22 @@ This can be measured with the :class:`~lightning.pytorch.callbacks.device_stats_
121
121
122
122
CPU metrics will be tracked by default on the CPU accelerator. To enable it for other accelerators set ``DeviceStatsMonitor(cpu_stats=True)``. To disable logging
123
123
CPU metrics, you can specify ``DeviceStatsMonitor(cpu_stats=False)``.
124
+
125
+
.. warning::
126
+
127
+
**Do not wrap** ``Trainer.fit()``, ``Trainer.validate()``, or other Trainer methods inside a manual
128
+
``torch.profiler.profile`` context manager. This will cause unexpected crashes and cryptic errors due to
129
+
incompatibility between PyTorch Profiler's context management and Lightning's internal training loop.
130
+
Instead, always use the ``profiler`` argument in the ``Trainer`` constructor or the
131
+
:class:`~lightning.pytorch.profilers.pytorch.PyTorchProfiler` profiler class if you want to customize the profiling.
132
+
133
+
Example:
134
+
135
+
.. code-block:: python
136
+
137
+
from lightning.pytorch import Trainer
138
+
from lightning.pytorch.profilers import PytorchProfiler
0 commit comments