Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x cuDNN_STATUS_ALLOC_尝试使用tensorflow运行教程CNN时失败_Python 3.x_Tensorflow_Deep Learning_Nvidia - Fatal编程技术网

Python 3.x cuDNN_STATUS_ALLOC_尝试使用tensorflow运行教程CNN时失败

Python 3.x cuDNN_STATUS_ALLOC_尝试使用tensorflow运行教程CNN时失败,python-3.x,tensorflow,deep-learning,nvidia,Python 3.x,Tensorflow,Deep Learning,Nvidia,我正在尝试使用卷积神经网络(CNN)运行一个简单的python脚本。每次运行脚本时,我都会遇到以下错误消息 2021-03-10 19:47:03.832061: E tensorflow/stream_executor/cuda/cuda_dnn.cc:328] Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED Traceback (most recent call last): File "CNN_trial.py

我正在尝试使用卷积神经网络(CNN)运行一个简单的python脚本。每次运行脚本时,我都会遇到以下错误消息

2021-03-10 19:47:03.832061: E tensorflow/stream_executor/cuda/cuda_dnn.cc:328] Could not create cudnn handle: CUDNN_STATUS_ALLOC_FAILED
Traceback (most recent call last):
  File "CNN_trial.py", line 17, in <module>
    outputs = tf.nn.conv2d(images,filters,strides = 1,padding = "SAME")
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 2158, in conv2d_v2
    return conv2d(input,  # pylint: disable=redefined-builtin
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\dispatch.py", line 201, in wrapper
    return target(*args, **kwargs)
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\nn_ops.py", line 2264, in conv2d
    return gen_nn_ops.conv2d(
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 942, in conv2d
    return conv2d_eager_fallback(
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_nn_ops.py", line 1031, in conv2d_eager_fallback
    _result = _execute.execute(b"Conv2D", 1, inputs=_inputs_flat, attrs=_attrs,
  File "D:\miniconda3\envs\tensorflow\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
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] 

似乎我需要设置内存增长。通过在脚本开头添加以下两行。我至少让它跑了

devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(devices[0],True)

您可能还有另一个代码实例仍在运行。因此,原始实例仍在使用GPU,您必须终止该GPU才能执行您想要执行的操作。我是否应该关闭所有可能运行该代码的其他应用程序?我正在使用VS代码,但没有打开另一个IDE运行任何代码。@BrainE可能在一个VS代码窗口中打开多个终端我关闭了除我正在使用的VS代码窗口之外的所有其他VS代码窗口,但仍然收到相同的错误
devices = tf.config.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(devices[0],True)