Skip to content

Commit 66e1c5c

Browse files
committed
Workaround for "WARNING: Logging before flag parsing goes to stderr."
Encountered with TensorFlow v1.14.0 on Traverse tensorflow/tensorflow#26691
1 parent c5dfa9d commit 66e1c5c

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

plasma/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
import logging
2+
try:
3+
import absl.logging
4+
# https://github.com/abseil/abseil-py/issues/99
5+
logging.root.removeHandler(absl.logging._absl_handler)
6+
# https://github.com/abseil/abseil-py/issues/102
7+
absl.logging._warn_preinit_stderr = False
8+
except Exception:
9+
pass
10+
111
import warnings
212
# TODO(KGF): temporarily suppress numpy>=1.17.0 warning with TF<2.0.0
313
# ~6x tensorflow/python/framework/dtypes.py:529: FutureWarning ...

plasma/models/mpi_runner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
from keras.utils.generic_utils import Progbar
106106
import keras.callbacks as cbks
107107

108+
g.flush_all_inorder()
108109
g.pprint_unique(conf)
109110
g.flush_all_inorder()
110111
g.comm.Barrier()
@@ -164,11 +165,9 @@ def __init__(self, lr):
164165
self.eps = 1e-8
165166

166167
def get_deltas(self, raw_deltas):
167-
168168
if self.iterations == 0:
169169
self.m_list = [np.zeros_like(grad) for grad in raw_deltas]
170170
self.v_list = [np.zeros_like(grad) for grad in raw_deltas]
171-
172171
t = self.iterations + 1
173172
lr_t = self.lr * np.sqrt(1-self.beta_2**t)/(1-self.beta_1**t)
174173
deltas = []
@@ -179,7 +178,6 @@ def get_deltas(self, raw_deltas):
179178
deltas.append(delta_t)
180179
self.m_list[i] = m_t
181180
self.v_list[i] = v_t
182-
183181
self.iterations += 1
184182

185183
return deltas

0 commit comments

Comments
 (0)