【深度学习】【TensorFlow程序报错】【cuDNN】Failed to get convolution algorithm

TensorFlow程序报错

程序报错

Traceback (most recent call last):
  File "E:/Pycharm Project/ImgSegBase/UNet_Training.py", line 127, in <module>
    callbacks=[checkpoint_period, reduce_lr])
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1829, in fit_generator
    initial_epoch=initial_epoch)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\keras\engine\training.py", line 108, in _method_wrapper
    return method(self, *args, **kwargs)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\keras\engine\training.py", line 1098, in fit
    tmp_logs = train_function(iterator)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\def_function.py", line 780, in __call__
    result = self._call(*args, **kwds)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\def_function.py", line 840, in _call
    return self._stateless_fn(*args, **kwds)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\function.py", line 2829, in __call__
    return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\function.py", line 1848, in _filtered_call
    cancellation_manager=cancellation_manager)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\function.py", line 1924, in _call_flat
    ctx, args, cancellation_manager=cancellation_manager))
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\function.py", line 550, in call
    ctx=ctx)
  File "C:\Users\1\Anaconda3\envs\TensorField\lib\site-packages\tensorflow\python\eager\execute.py", line 60, in quick_execute
    inputs, attrs, num_outputs)
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.
	 [[node functional_1/conv1/Conv2D (defined at E:/Pycharm Project/ImgSegBase/UNet_Training.py:127) ]] [Op:__inference_train_function_7730]

Function call stack:
train_function

2021-02-12 13:48:05.362343: 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.
	 [[{{node PyFunc}}]]


解决方法

import tensorflow as tf
config = tf.compat.v1.ConfigProto(allow_soft_placement=True)
config.gpu_options.per_process_gpu_memory_fraction = 0.2
tf.compat.v1.keras.backend.set_session(tf.compat.v1.Session(config=config))

参考文献

[1] https://blog.csdn.net/qq_29969029/article/details/108415432

上一篇:pip install imgaug安装失败解决办法


下一篇:pycharm ctrl+点击无法跳转问题(connot find declaration to go to)