The environment configuration is Ubuntu 16.04, tensorflow 1.13.1, cuda10, cudnn7.6.4.
Error when running tensorflow code
UnknownError (see above for traceback): 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.
With the tensorflow, cuda, and cudnn versions corresponding correctly, add the following code to the code.
import os os.environ['CUDA_VISIBLE_DEVICES'] = "0" config = tf.ConfigProto() config.allow_soft_placement=True # If the device you specify does not exist, allow TF to allocate the device automatically config.gpu_options.per_process_gpu_memory_fraction = 0.9 #Allocate a portion of the video memory to the program to avoid memory overflow config.gpu_options.allow_growth = True #Allocate video memory on demand with tf.Session(config=config) as sess: #Your Codes