I checked this tutorial PyTorch Profiler With TensorBoard — PyTorch Tutorials 1.8.1+cu102 documentation on CPU only.
I got the following error
p.step()

File “torch/profiler/profiler.py”, line 230, in exit
self._exit_actions()
File “torch/profiler/profiler.py”, line 346, in _exit_actions
self._start_trace()
File “torch/profiler/profiler.py”, line 367, in _start_trace
assert self.profiler is not None
AssertionError