Skip to content

Commit df928db

Browse files
Update profiler.rst
1 parent 989b759 commit df928db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/source-pytorch/tuning/profiler.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ Find bottlenecks in your code
1111

1212
.. Add callout items below this line
1313
14+
.. warning::
15+
16+
Do **not** wrap ``Trainer.fit()``, ``Trainer.validate()``, or similar Trainer methods inside a manual ``torch.profiler.profile`` context manager.
17+
This will cause unexpected crashes and cryptic errors due to incompatibility between PyTorch Profiler's context and Lightning's training loop.
18+
Instead, use the ``profiler`` argument of the ``Trainer``:
19+
20+
.. code-block:: python
21+
22+
trainer = pl.Trainer(
23+
profiler="pytorch", # This is the correct and supported way
24+
...
25+
)
26+
1427
.. displayitem::
1528
:header: Basic
1629
:description: Learn to find bottlenecks in the training loop.

0 commit comments

Comments
 (0)