报错:
原因:可能是显存不足
解决方法:
(1):设置GPU内存按需分配
gpu_options = tf.GPUOptions(allow_growth=True)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))# sess = tf.InteractiveSession(config=tf.ConfigProto(gpu_options=gpu_options))
(2)在代码的最顶端添加如下代码:
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
tf.config.experimental.set_memory_growth(physical_devices[0], True)
(3)将图片大小设置小点