Error occurred when finalizing GeneratorDataset iterator

created at 09-30-2021 views: 57

error

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.

Checking the blog online said that the batchsize setting is too large, resulting in insufficient memory. So I changed the batchsize from 16 to 4, and then changed it to 1. This error still occurs.
I feel that the model I ran is not too big, why does this kind of problem occur?

solution

It is not set when the GPU is called
Just add these two lines of code at the top of the code

config = tf.compat.v1.ConfigProto(gpu_options=tf.compat.v1.GPUOptions(allow_growth=True))
sess = tf.compat.v1.Session(config=config)
created at:09-30-2021
edited at: 09-30-2021: