Skip to content

Commit 99671e4

Browse files
Prevent TF from logging info messages during data collection (#93)
Currently, whenever a TF model gets loaded in by LLVM in the development mode advisors, TF outputs a slew of info messages to STDOUT that aren't particularly useful. This patch gets rid of those messages by setting an environment variable when running the compilation commands that only enables warnings and errors to be printed to the console. This makes it much easier to see progress/results in several of the scripts within this repository such as train_locally.py and generate_default_trace.py when grabbing performance data for a policy.
1 parent 04017d9 commit 99671e4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler_opt/rl/compilation_runner.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import abc
1818
import dataclasses
1919
import json
20+
import os
2021
import subprocess
2122
import threading
2223
from typing import Dict, List, Optional, Tuple
@@ -30,6 +31,8 @@
3031
_COMPILATION_TIMEOUT = flags.DEFINE_integer(
3132
'compilation_timeout', 60,
3233
'Max duration (in seconds) after which we cancel any compilation job.')
34+
_QUIET = flags.DEFINE_bool(
35+
'quiet', True, 'Whether or not to compile quietly (hiding info logging)')
3336

3437

3538
def _calculate_reward(policy: float, baseline: float) -> float:
@@ -152,8 +155,14 @@ def start_cancellable_process(
152155
TimeoutExpired: if the process times out.
153156
ProcessKilledError: if the process was killed via the cancellation token.
154157
"""
158+
command_env = os.environ.copy()
159+
# Disable tensorflow info messages during data collection
160+
if _QUIET.value:
161+
command_env['TF_CPP_MIN_LOG_LEVEL'] = '1'
155162
with subprocess.Popen(
156-
cmdline, stdout=(subprocess.PIPE if want_output else None)) as p:
163+
cmdline,
164+
env=command_env,
165+
stdout=(subprocess.PIPE if want_output else None)) as p:
157166
if cancellation_manager:
158167
cancellation_manager.register_process(p)
159168

0 commit comments

Comments
 (0)