Skip to content

Commit 01ce9b9

Browse files
000draxnfelt
authored andcommitted
Add --samples_per_plugin to specify explicit sampling counts
1 parent 11e138e commit 01ce9b9

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

tensorboard/backend/application.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,20 @@
7171
_VALID_PLUGIN_RE = re.compile(r'^[A-Za-z0-9_.-]+$')
7272

7373

74+
def tensor_size_guidance_from_flags(flags):
75+
"""Apply user per-summary size guidance overrides."""
76+
77+
tensor_size_guidance = dict(DEFAULT_TENSOR_SIZE_GUIDANCE)
78+
if not flags or not flags.samples_per_plugin:
79+
return tensor_size_guidance
80+
81+
for token in flags.samples_per_plugin.split(','):
82+
k, v = token.strip().split('=')
83+
tensor_size_guidance[k] = int(v)
84+
85+
return tensor_size_guidance
86+
87+
7488
def standard_tensorboard_wsgi(
7589
logdir,
7690
purge_orphaned_data,
@@ -90,13 +104,13 @@ def standard_tensorboard_wsgi(
90104
reload_interval: The interval at which the backend reloads more data in
91105
seconds. Zero means load once at startup; negative means never load.
92106
plugins: A list of constructor functions for TBPlugin subclasses.
93-
path_prefix: A prefix of the path when app isn't served from root.
94107
db_uri: A String containing the URI of the SQL database for persisting
95108
data, or empty for memory-only mode.
96109
assets_zip_provider: See TBContext documentation for more information.
97110
If this value is not specified, this function will attempt to load
98111
the `tensorboard.default` module to use the default. This behavior
99112
might be removed in the future.
113+
path_prefix: A prefix of the path when app isn't served from root.
100114
window_title: A string specifying the the window title.
101115
max_reload_threads: The max number of threads that TensorBoard can use
102116
to reload runs. Not relevant for db mode. Each thread reloads one run
@@ -110,7 +124,7 @@ def standard_tensorboard_wsgi(
110124
assets_zip_provider = default.get_assets_zip_provider()
111125
multiplexer = event_multiplexer.EventMultiplexer(
112126
size_guidance=DEFAULT_SIZE_GUIDANCE,
113-
tensor_size_guidance=DEFAULT_TENSOR_SIZE_GUIDANCE,
127+
tensor_size_guidance=tensor_size_guidance_from_flags(flags),
114128
purge_orphaned_data=purge_orphaned_data,
115129
max_reload_threads=max_reload_threads)
116130
db_module, db_connection_provider = get_database_info(db_uri)

tensorboard/program.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@
128128
'The max number of threads that TensorBoard can use to reload runs. Not '
129129
'relevant for db mode. Each thread reloads one run at a time.')
130130

131+
tf.flags.DEFINE_string(
132+
'samples_per_plugin', '', 'An optional comma separated list of '
133+
'plugin_name=num_samples pairs to explicitly specify how many samples to '
134+
'keep per tag for that plugin. For unspecified plugins, TensorBoard '
135+
'randomly downsamples logged summaries to reasonable values to prevent '
136+
'out-of-memory errors for long running jobs. This flag allows fine control '
137+
'over that downsampling. Note that 0 means keep all samples of that type. '
138+
'For instance, "scalars=500,images=0" keeps 500 scalars and all images. '
139+
'Most users should not need to set this flag.')
140+
131141
FLAGS = tf.flags.FLAGS
132142

133143

0 commit comments

Comments
 (0)