Tag Archives: Tensorflow GPU Error

TensorFlow-gpu Error: failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected

Error Messages:

failed call to cuInit: CUDA_ERROR_NO_Device: no CUDA capable device is detected
this is also what I encountered when running a CNN SVM classifier program of tensorflow GPU today. It’s not the problem of the program. It’s our graphics card.

Solution:

import tensorflow as tf

config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.compat.v1.InteractiveSession(config=config)

Just add these lines of code to the head of the code, and you don’t need to write this code belowos.environ['CUDA_VISIBLE_DEVICES'] = '/gpu:0'

Error using tensorflow GPU: could not create cudnn handle: cudnn_STATUS_NOT_INITIALIZED

Error in using Tensorflow-GPU:
Error

Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
***Error: 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.

The error mainly points to cudnn, but the CUDA version and cudnn version are in line with the current tensorflow requirements (meaning there is no need to change the CUDA version and cudnn version)
, so it can only be caused by GPU use problem (meaning it is not the fault caused by the program needs to call GPU for many times)
The solution: **
Set GPU on-demand allocation mode
Tensorflow – GPU 2.3.1(be aware of the version of TensorFlow)****

config= tf.compat.v1.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.7 #0.7parameter, meaning the percentage allocated to gpu-memory.
sess=tf.compat.v1.Session(config=config)

Older version of TensorFlow-GPU

`config= tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.7 #0.7parameter, meaning the percentage allocated to gpu-memory.
sess=tf.Session(config=config)`

* Set GPU to apply video memory dynamically
Tensorflow – GPU 2.3.1(be aware of the version of TensorFlow)****

config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.compat.v1.Session(config=config)

Older version of TensorFlow-GPU

`config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)

Please insert the above code into the front of any part of the program to solve the problem