dlerror: cusparse64_11.dll not found. Cannot detetct...

1. tensorflow版本和CUDA版本匹配

dlerror: cusparse64_11.dll not found. Cannot detetct

遇到如上问题,是因为tensorflow-gpu版本过高,降低tensorflow版本即可

如果是2.0以上的tensorflow,按下面列表安装(2021年3月更新官网链接

TFCUDAcudnn
2.010.07.6
2.110.17.6
2.210.17.6
2.310.17.6
2.411.08.0

可以看到tensorflow-gpu 2.4 对应了11.0的CUDA,所以降低tensorflow-gpu版本即可

下面命令可以显示可安装版本,如果出错,升级pip。

pip install tensorflow-gpu== 

降低tensorflow-gpu版本到对应自己的cuda即可使用gpu。

2. GPU测试

2.1 测试所有设备

from tensorflow.python.client import device_lib
import tensorflow as tf

print(device_lib.list_local_devices())
print(tf.test.is_built_with_cuda())

测试结果: 

 

2.2 测试gpu效果 

import timeit

import matplotlib.pyplot as plt
import tensorflow as tf

'''
以矩阵A[10,n]和矩阵B[n,10]的乘法运算(分别在cpu和gpu上运行)来测试,
'''


def cpu_gpu_compare(n):
    with tf.device('/cpu:0'):  # 指定操作用cpu计算
        cpu_a = tf.random.normal([10, n])  # 生成符合高斯分布的随机数矩阵,通过改变n大小,增减计算量
        cpu_b = tf.random.normal([n, 10])
    print(cpu_a.device, cpu_b.device)
    with tf.device('/gpu:0'):
        gpu_a = tf.random.normal([10, n])
        gpu_b = tf.random.normal([n, 10])
    print(gpu_a.device, gpu_b.device)

    def cpu_run():
        with tf.device('/cpu:0'):  # 矩阵乘法,此操作采用cpu计算
            c = tf.matmul(cpu_a, cpu_b)
        return c

    def gpu_run():
        with tf.device('/gpu:0'):  # 矩阵乘法,此操作采用gpu计算
            c = tf.matmul(gpu_a, gpu_b)
        return c

    # 第一次计算需要热身,避免将初始化时间计算在内
    cpu_time = timeit.timeit(cpu_run, number=10)
    gpu_time = timeit.timeit(gpu_run, number=10)
    print('warmup:', cpu_time, gpu_time)
    # 正式计算10次,取平均值
    cpu_time = timeit.timeit(cpu_run, number=10)
    gpu_time = timeit.timeit(gpu_run, number=10)
    print('run_time:', cpu_time, gpu_time)
    return cpu_time, gpu_time


# n_list1 = range(1, 2000, 5)
# n_list2 = range(2001, 10000, 100)
n_list3 = range(100000, 1000000, 50000)
# n_list = list(n_list1) + list(n_list2)
n_list = n_list3
time_cpu = []
time_gpu = []
for n in n_list:
    t = cpu_gpu_compare(n)
    time_cpu.append(t[0])
    time_gpu.append(t[1])
plt.plot(n_list, time_cpu, color='red', label='cpu')
plt.plot(n_list, time_gpu, color='green', linewidth=1.0, linestyle='--', label='gpu')
plt.ylabel('耗时', fontproperties='SimHei', fontsize=20)
plt.xlabel('计算量', fontproperties='SimHei', fontsize=20)
plt.title('cpu和gpu计算力比较', fontproperties='SimHei', fontsize=30)
plt.legend(loc='upper right')
plt.show()

测试结果:

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
dlerror: cublaslt64_11.dll not found 是一个错误消息,有关 CUDA 库中的文件 cublaslt64_11.dll 找不到。这个错误通常出现在使用 NVIDIA 的 CUDA 库进行 GPU 编程时。 要解决这个问题,你可以尝试以下几种方法: 1. 检查 CUDA 安装:首先,确保你已经正确安装了 CUDA 工具包,并且在系统环境变量中添加了正确的 CUDA 路径。如果没有正确安装 CUDA 或设置环境变量,你可以重新安装 CUDA 或者更新环境变量设置。 2. 检查依赖文件:确认 cublaslt64_11.dll 文件是否存在于你的系统中的正确位置。这个文件通常位于 CUDA 安装目录的 bin 文件夹下。如果文件确实不存在,你可以尝试重新安装 CUDA,或者从其他来源获取正确版本的文件。 3. 检查库版本:确保你正在使用的 CUDA 库与你的应用程序或代码兼容。不同的 CUDA 版本可能要求不同的库文件。你可以查看 CUDA 文档或官方网站了解不同版本之间的兼容性,并相应地更新或切换到正确的 CUDA 版本。 4. 更新驱动程序:如果你的 GPU 驱动程序已过时,也可能导致此错误。尝试更新你的 NVIDIA GPU 驱动程序,并确保与当前使用的 CUDA 版本兼容。 总之,当出现 dlerror: cublaslt64_11.dll not found 错误时,你需要检查 CUDA 的安装和配置,确认依赖文件是否存在,并确保库版本与应用程序兼容。如果问题仍然存在,可以尝试重新安装 CUDA 或更新 GPU 驱动程序来解决此问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值