运行程序时出现这个错误Error occurred when finalizing GeneratorDataset iterator

tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [Op:Conv2D]
2021-09-24 15:31:45.989272: W tensorflow/core/kernels/data/generator_dataset_op.cc:103] Error occurred when finalizing GeneratorDataset iterator: Failed precondition: Python interpreter state is not initialized. The process may be terminated.

上网查博客说是batchsize设置太大,导致的内存不足。于是把batchsize从16改成4,又改成1,还是出现这个错误。
感觉我跑的这个模型也没有很大呀,为什么会出现这种问题
解决啦!
是在调用GPU的时候没有设置好
在代码顶部加上这两行代码就行
config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True))
sess = tf.compat.v1.Session(config=config)

你可能感兴趣的:(tensorflow)