Tensorflow常见报错处理

1. CUDA_ERROR_OUT_OF_MEMORY
import tensorflow as tf

# 避免 CUDA_ERROR_OUT_OF_MEMORY
config = tf.ConfigProto(allow_soft_placement=True)
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
config.gpu_options.allow_growth = True

sess = tf.Session(config=config)

a = tf.placeholder("float")
b = tf.placeholder("float")
c = tf.constant(6.0)
d = tf.multiply(a, b)
y = tf.multiply(d, c)
print sess.run(y, feed_dict={a: 3, b: 3})
原文地址:https://www.cnblogs.com/zengcv/p/6956359.html