|
Safemotion Lib
|
Public Member Functions | |
| __init__ (self, enable_predicate, output_dir, *use_cuda=True) | |
| before_step (self) | |
| after_step (self) | |
Public Member Functions inherited from fastreid.engine.train_loop.HookBase | |
| before_train (self) | |
| after_train (self) | |
Public Attributes | |
| trainer | |
Protected Attributes | |
| _enable_predicate | |
| _use_cuda | |
| _output_dir | |
| _profiler | |
A hook which runs `torch.autograd.profiler.profile`.
Examples:
.. code-block:: python
hooks.AutogradProfiler(
lambda trainer: trainer.iter > 10 and trainer.iter < 20, self.cfg.OUTPUT_DIR
)
The above example will run the profiler for iteration 10~20 and dump
results to ``OUTPUT_DIR``. We did not profile the first few iterations
because they are typically slower than the rest.
The result files can be loaded in the ``chrome://tracing`` page in chrome browser.
Note:
When used together with NCCL on older version of GPUs,
autograd profiler may cause deadlock because it unnecessarily allocates
memory on every device it sees. The memory management calls, if
interleaved with NCCL calls, lead to deadlock on GPUs that do not
support `cudaLaunchCooperativeKernelMultiDevice`.
| fastreid.engine.hooks.AutogradProfiler.__init__ | ( | self, | |
| enable_predicate, | |||
| output_dir, | |||
| * | use_cuda = True ) |
Args:
enable_predicate (callable[trainer -> bool]): a function which takes a trainer,
and returns whether to enable the profiler.
It will be called once every step, and can be used to select which steps to profile.
output_dir (str): the output directory to dump tracing files.
use_cuda (bool): same as in `torch.autograd.profiler.profile`.
Definition at line 252 of file hooks.py.
| fastreid.engine.hooks.AutogradProfiler.after_step | ( | self | ) |
Called after each iteration.
Reimplemented from fastreid.engine.train_loop.HookBase.
Definition at line 272 of file hooks.py.
| fastreid.engine.hooks.AutogradProfiler.before_step | ( | self | ) |
Called before each iteration.
Reimplemented from fastreid.engine.train_loop.HookBase.
Definition at line 265 of file hooks.py.
|
protected |
|
protected |