Skip to content

Instantly share code, notes, and snippets.

@cshjin
Last active November 20, 2019 17:08
Show Gist options
  • Save cshjin/0e44317085d2c186cda1aa15bb126dfb to your computer and use it in GitHub Desktop.
Save cshjin/0e44317085d2c186cda1aa15bb126dfb to your computer and use it in GitHub Desktop.
Clean up the log info in running tf
try:
# import tf 2.X
import tensorflow.compat.v2 as tf
except Exception:
# import tf 1.X
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
print('Using TF {}'.format(tf.__version__))
# set logging level for tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# set warning level for numpy
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.simplefilter(action='ignore', category=DeprecationWarning)
import numpy as np
print(tf.test.is_gpu_available())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment