Check failed: cusolverDnCreate(&cusolver_dn_handle) == CUSOLVER_STATUS_SUCCESS Failed to create cuSo

报错信息:
Check failed: cusolverDnCreate(&cusolver_dn_handle) == CUSOLVER_STATUS_SUCCESS Failed to create cuSolverDN instance.

解决办法:
没有成功调用CUSOLVER库,很多解释是版本不匹配,还有GPU内存占满的情况,可以尝试以下办法:

import tensorflow as tf

# 列出所有可用的GPU设备
physical_devices = tf.config.list_physical_devices('GPU')

# 尝试设置第一个GPU的内存增长选项
try:
    tf.config.experimental.set_memory_growth(physical_devices[0], True)
except IndexError:
    print("No GPU found.")
except RuntimeError as e:
    # 如果设备无效或者已经初始化,则捕获异常
    print(f"Error setting memory growth: {e}")

但是我的问题查询很久发现是tensor无法成功调用GPU导致,主要是因为cudnn未正确安装导致库的缺失。可以自行测试GPU是否成功调用

import tensorflow as tf

print(tf.__version__)
print(tf.test.gpu_device_name())
print(tf.config.experimental.set_visible_devices)
print('GPU:', tf.config.list_physical_devices('GPU'))
print('CPU:', tf.config.list_physical_devices(device_type='CPU'))
print(tf.config.list_physical_devices('GPU'))
print(tf.test.is_gpu_available())
# 输出可用的GPU数量
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

可以下载加装cudnn解决该问题。

猜你喜欢

转载自blog.csdn.net/sept_boy/article/details/140933693