mirror of https://github.com/open-mmlab/mmcv.git
[Enhancement] Improve ProfilerHook beaviour when using a relative (or empty) dir_name (#2119)
* Add default dir_name and make non-absolute dir_name relative to runner.work_dir * Add log message and change default dir namepull/2125/head^2
parent
b58c84c6f0
commit
0092699fef
|
@ -1,4 +1,5 @@
|
|||
# Copyright (c) OpenMMLab. All rights reserved.
|
||||
import os.path as osp
|
||||
import warnings
|
||||
from typing import Callable, List, Optional, Union
|
||||
|
||||
|
@ -131,6 +132,15 @@ class ProfilerHook(Hook):
|
|||
raise ImportError('please run "pip install '
|
||||
'torch-tb-profiler" to install '
|
||||
'torch_tb_profiler')
|
||||
if 'dir_name' not in trace_cfg:
|
||||
trace_cfg['dir_name'] = osp.join(runner.work_dir,
|
||||
'tf_tracing_logs')
|
||||
elif not osp.isabs(trace_cfg['dir_name']):
|
||||
trace_cfg['dir_name'] = osp.join(runner.work_dir,
|
||||
trace_cfg['dir_name'])
|
||||
runner.logger.info(
|
||||
'tracing files of ProfilerHook will be saved to '
|
||||
f"{trace_cfg['dir_name']}.")
|
||||
_on_trace_ready = torch.profiler.tensorboard_trace_handler(
|
||||
**trace_cfg)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue