FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Suppress most TensorFlow deprecation warnings with external Keras · PPPLDeepLearning/plasma-python@aa2fd04 · GitHub

Commit aa2fd04

Browse files
committed
Suppress most TensorFlow deprecation warnings with external Keras
1 parent 66e1c5c commit aa2fd04

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

‎plasma/__init__.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import logging
23
try:
34
import absl.logging
@@ -15,3 +16,12 @@
1516
category=FutureWarning,
1617
message=r"passing \(type, 1\) or '1type' as a synonym of type is deprecated", # noqa
1718
module="tensorflow")
19+
20+
# Optional: disable the C-based library diagnostic info and warning messages:
21+
# 2019-11-06 18:27:31.698908: I ... dynamic library libcublas.so.10
22+
# (independent from tf.logging.set_verbosity() diagnostic control)
23+
# Must be set before first import of tensorflow v0.12+
24+
# (either directly or via Keras backend)
25+
# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
26+
# Ref: https://github.com/tensorflow/tensorflow/issues/1258
27+
# https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information/38645250#38645250 # noqa

‎plasma/models/mpi_runner.py‎

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
# But many TF deprecation warnings in 1.14.0, e.g.:
7070
# "The name tf.GPUOptions is deprecated. Please use tf.compat.v1.GPUOptions
7171
# instead". See tf_export.py
72-
if tf_ver > parse_version('1.13.0'):
72+
if tf_ver >= parse_version('1.13.0'):
7373
import tensorflow.compat.v1 as tf
7474
else:
7575
import tensorflow as tf
@@ -86,7 +86,6 @@
8686
config = tf.ConfigProto(gpu_options=gpu_options)
8787
set_session(tf.Session(config=config))
8888
g.flush_all_inorder()
89-
g.comm.Barrier()
9089
else:
9190
os.environ['KERAS_BACKEND'] = 'theano'
9291
base_compile_dir = '{}/tmp/{}-{}'.format(
@@ -143,7 +142,6 @@ def __init__(self, lr):
143142

144143
def get_deltas(self, raw_deltas):
145144
deltas = []
146-
147145
if self.iterations == 0:
148146
self.velocity_list = [np.zeros_like(g) for g in raw_deltas]
149147

@@ -784,7 +782,34 @@ def mpi_train(conf, shot_list_train, shot_list_validate, loader,
784782
conf['num_workers'] = g.comm.Get_size()
785783

786784
specific_builder = builder.ModelBuilder(conf)
785+
786+
# TODO(KGF): next line suppresses ALL info and warning messages, not just
787+
# deprecation warnings...
788+
# tf.logging.set_verbosity(tf.logging.ERROR)
789+
790+
# Internal TensorFlow flags, subject to change (v1.14.0+ only?)
791+
try:
792+
from tensorflow.python.util import module_wrapper as deprecation
793+
except ImportError:
794+
from tensorflow.python.util import deprecation_wrapper as deprecation
795+
# deprecation._PRINT_DEPRECATION_WARNINGS = False # does nothing
796+
deprecation._PER_MODULE_WARNING_LIMIT = 0
797+
# Suppresses warnings from "keras/backend/tensorflow_backend.py", except:
798+
# "Rate should be set to `rate = 1 - keep_prob`"
799+
# Also suppresses warnings from "keras/optimizers.py
800+
# does NOT suppresses warn from "/tensorflow/python/ops/math_grad.py"
801+
802+
# TODO(KGF): for TF>v1.13.0 (esp v1.14.0), this next line prompts a ton of
803+
# deprecation warnings with externally-packaged Keras, e.g.:
804+
# WARNING:tensorflow:From .../keras/backend/tensorflow_backend.py:174:
805+
# The name tf.get_default_session is deprecated.
806+
# Please use tf.compat.v1.get_default_session instead.
787807
train_model = specific_builder.build_model(False)
808+
# Cannot fix these Keras internals via "import tensorflow.compat.v1 as tf"
809+
#
810+
# TODO(KGF): note, these are different than C-based info diagnostics e.g.:
811+
# 2019-11-06 18:27:31.698908: I ... dynamic library libcublas.so.10
812+
# which are NOT suppressed by set_verbosity. See top level __init__.py
788813

789814
# load the latest epoch we did. Returns -1 if none exist yet
790815
e = specific_builder.load_model_weights(train_model)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL