File size: 505 Bytes
1f85df6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import tensorflow as tf


def fix_tf_gpu():
    '''
    Fix for the following error message:
    UnknownError: Failed to get convolution algorithm. 
    This is probably because cuDNN failed to initialize...

    More:
    https://www.tensorflow.org/api_docs/python/tf/config/experimental/set_memory_growth
    '''

    physical_devices = tf.config.experimental.list_physical_devices('GPU')
    
    try:
        tf.config.experimental.set_memory_growth(physical_devices[0], True)
    except:
        pass