# 如何在tensorflow中屏蔽Debug信息

import tensorflow as tf
tf.__version__

import tensorflow as tf
import numpy as np

# 使用 NumPy 生成假数据(phony data), 总共 100 个点.
x_data = np.float32(np.random.rand(2, 100)) # 随机输入
y_data = np.dot([0.100, 0.200], x_data) + 0.300

# 构造一个线性模型
#
b = tf.Variable(tf.zeros([1]))
W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0))
y = tf.matmul(W, x_data) + b

# 最小化方差
loss = tf.reduce_mean(tf.square(y - y_data))
train = optimizer.minimize(loss)

# 初始化变量
init = tf.global_variables_initializer()

# 启动图 (graph)
sess = tf.Session();
sess.run(init);

# 拟合平面
for step in range(0, 201):
sess.run(train)
if step % 20 == 0:
print(step, sess.run(W), sess.run(b))

2017-11-13 15:16:43.546962: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1061] Found device 0 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:04:00.0
totalMemory: 10.91GiB freeMemory: 4.21GiB
2017-11-13 15:16:43.714859: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1061] Found device 1 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:03:00.0
totalMemory: 10.91GiB freeMemory: 3.64GiB
2017-11-13 15:16:43.908690: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1061] Found device 2 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:02:00.0
totalMemory: 10.91GiB freeMemory: 1.34GiB
2017-11-13 15:16:44.164129: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1061] Found device 3 with properties:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.62
pciBusID: 0000:01:00.0
totalMemory: 10.91GiB freeMemory: 5.61GiB
2017-11-13 15:16:44.168588: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1076] Device peer to peer matrix
2017-11-13 15:16:44.168635: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1082] DMA: 0 1 2 3
2017-11-13 15:16:44.168642: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1092] 0:   Y Y Y Y
2017-11-13 15:16:44.168647: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1092] 1:   Y Y Y Y
2017-11-13 15:16:44.168651: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1092] 2:   Y Y Y Y
2017-11-13 15:16:44.168655: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1092] 3:   Y Y Y Y
2017-11-13 15:16:44.168664: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1151] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:04:00.0, compute capability: 6.1)
2017-11-13 15:16:44.168669: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1151] Creating TensorFlow device (/device:GPU:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:03:00.0, compute capability: 6.1)
2017-11-13 15:16:44.168675: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1151] Creating TensorFlow device (/device:GPU:2) -> (device: 2, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1)
2017-11-13 15:16:44.168679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1151] Creating TensorFlow device (/device:GPU:3) -> (device: 3, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)


import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
#默认为0：输出所有log信息
#设置为1：进一步屏蔽INFO信息
#设置为2：进一步屏蔽WARNING信息
#设置为3：进一步屏蔽ERROR信息

https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information