tensorflow使用笔记

1. 运行训练代码时报如下错误

could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
可能是显存问题

解决办法:
使用allow_growth控制GPU的内存分配,代码如下

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)
gpu_options=tf.GPUOptions(allow_growth=True)
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:

1. 运行训练代码时报如下错误

could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR

could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM

可能是显存问题

解决办法:

使用allow_growth控制GPU的内存分配,代码如下

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)
gpu_options=tf.GPUOptions(allow_growth=True)
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:

或者
我设为0.75有效,0.8还是报错

config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.4
session = tf.Session(config=config, ...)

你可能感兴趣的:(tensorflow使用笔记)