错误原因:GPU资源占用太大
config = tf.ConfigProto(allow_soft_placement=True)
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
config.gpu_options.allow_growth = True
找到如下红的的这句话,在这之前加上如上三行代码,在session前约束占用空间。能够使得tensorflow占用资源降至70%,当然也可以改为50%,而不是整个服务器GPU
with tf.Session() as sess:
将其改为
with tf.Session(config=config) as sess:
最终改为如下结构就可以啦
config = tf.ConfigProto(allow_soft_placement=True)
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
网友评论