Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
47c98ec2
Commit
47c98ec2
authored
Jun 21, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Profiler can dump both RunMetadata and tracing (#309)
parent
0459677e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
tensorpack/callbacks/prof.py
tensorpack/callbacks/prof.py
+22
-7
No files found.
tensorpack/callbacks/prof.py
View file @
47c98ec2
...
@@ -95,20 +95,26 @@ class GPUUtilizationTracker(Callback):
...
@@ -95,20 +95,26 @@ class GPUUtilizationTracker(Callback):
class
GraphProfiler
(
Callback
):
class
GraphProfiler
(
Callback
):
"""
"""
Enable profiling by installing session hooks,
Enable profiling by installing session hooks,
and write tracing files to ``logger.LOG_DIR``.
and write metadata or tracing files to ``logger.LOG_DIR``.
The tracing files can be loaded from ``chrome://tracing``.
The tracing files can be loaded from ``chrome://tracing``.
The metadata files can be processed by
`tfprof command line utils
<https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/tfprof/g3doc/command_line.md>`_.
Note that the profiling is enabled for every step.
Note that the profiling is enabled for every step.
You probably want to schedule it less frequently by
You probably want to schedule it less frequently by
:class:`PeriodicRunHooks`.
:class:`PeriodicRunHooks`.
"""
"""
def
__init__
(
self
,
show_memory
=
Fals
e
):
def
__init__
(
self
,
dump_metadata
=
False
,
dump_tracing
=
Tru
e
):
"""
"""
Args:
Args:
show_memory(bool): show tensor allocation in the tracing.
dump_metadata(bool): Dump :class:`tf.RunMetadata` to be used with tfprof.
dump_tracing(bool): Dump chrome tracing files.
"""
"""
self
.
_dir
=
logger
.
LOG_DIR
self
.
_dir
=
logger
.
LOG_DIR
self
.
_show_memory
=
bool
(
show_memory
)
self
.
_dump_meta
=
bool
(
dump_metadata
)
self
.
_dump_tracing
=
bool
(
dump_tracing
)
assert
os
.
path
.
isdir
(
self
.
_dir
)
assert
os
.
path
.
isdir
(
self
.
_dir
)
def
_before_run
(
self
,
_
):
def
_before_run
(
self
,
_
):
...
@@ -118,12 +124,21 @@ class GraphProfiler(Callback):
...
@@ -118,12 +124,21 @@ class GraphProfiler(Callback):
def
_after_run
(
self
,
_
,
run_values
):
def
_after_run
(
self
,
_
,
run_values
):
meta
=
run_values
.
run_metadata
meta
=
run_values
.
run_metadata
self
.
_write_chrome_trace
(
meta
)
if
self
.
_dump_meta
:
self
.
_write_meta
(
meta
)
if
self
.
_dump_tracing
:
self
.
_write_tracing
(
meta
)
def
_write_meta
(
self
,
metadata
):
fname
=
os
.
path
.
join
(
self
.
_dir
,
'runmetadata-{}.pb'
.
format
(
self
.
global_step
))
with
open
(
fname
,
'wb'
)
as
f
:
f
.
write
(
metadata
.
SerializeToString
())
def
_write_
chrome_trace
(
self
,
metadata
):
def
_write_
tracing
(
self
,
metadata
):
tl
=
timeline
.
Timeline
(
step_stats
=
metadata
.
step_stats
)
tl
=
timeline
.
Timeline
(
step_stats
=
metadata
.
step_stats
)
fname
=
os
.
path
.
join
(
fname
=
os
.
path
.
join
(
self
.
_dir
,
'chrome-trace-{}.json'
.
format
(
self
.
global_step
))
self
.
_dir
,
'chrome-trace-{}.json'
.
format
(
self
.
global_step
))
with
open
(
fname
,
'w'
)
as
f
:
with
open
(
fname
,
'w'
)
as
f
:
f
.
write
(
tl
.
generate_chrome_trace_format
(
f
.
write
(
tl
.
generate_chrome_trace_format
(
show_dataflow
=
True
,
show_memory
=
self
.
_show_memory
))
show_dataflow
=
True
,
show_memory
=
True
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment