报错:Could not load dynamic library ‘cudart64_110.dll‘; dlerror: cudart64_110.dll not found Ignore abo

报错:Could not load dynamic library ‘cudart64_110.dll‘; dlerror: cudart64_110.dll not found Ignore above

tensorflow使用过程中出现问题(第一次安装使用)

问题背景

RTX4070显卡,英伟达驱动的cuda版本12.3,下载了CUDA Toolkit12.3和对应的cudnn8.9,因为想着用新版本的开跑代码:
在这里插入图片描述
在使用pycharm运行如下的tensorflow-gpu测试代码:

import tensorflow as tf

gpu_device_name = tf.test.gpu_device_name()
print(gpu_device_name)

print(tf.test.is_gpu_available())

# 列出所有的本地机器设备
local_device_protos = tf.config.list_physical_devices('GPU')
# 打印
print(local_device_protos)

得到报错:

Could not load dynamic library ‘cudart64_110.dll‘; dlerror: cudart64_110.dll not found Ignore abo

问题分析

其根本原因是CUDA TOOLKIT的安装问题,首先确认安装目录究竟有没有这个dll文件,从自己的安装地址去找(例如:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\bin):
在这里插入图片描述
此处有两种情况,如果找到了则是环境变量有问题,看看有没有添加NVIDIA GPU Computing Toolkit\CUDA\v12.3\bin的系统变量;如果没有找到,就是CUDA TOOLKIT的安装版本有问题。参考我的实测正确的系统环境变量的设置:
在这里插入图片描述

我这边的问题是安装版本的问题,虽然英伟达的驱动的CUDA版本是12.3,但是tensorflow-gpu.10.0支持的最高的CUDA TOOLKIT的版本是11.2 ,见对应关系官网
在这里插入图片描述
此外,从tensorflow-gpu.10.0以上的更高版本,在windows版本已经不区分gpu版本和cpu版本了,所以暂时推荐使用tensorflow-gpu.10.0以防各种麻烦。

问题解决

虽然是RTX4070显卡,虽然英伟达驱动的cuda版本12.3,但是如果要用tensorflow-gpu必须安装老版本的CUDA TOOLKIT(11.2)和cudnn(8.1),不然没法跑。Pytorch相比没有这种问题。

运行之前的测试代码,已经检测到GPU 4070了:

2023-11-21 11:10:22.602796: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
/device:GPU:0
True
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
2023-11-21 11:10:23.064863: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 9458 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 4070, pci bus id: 0000:01:00.0, compute capability: 8.9
WARNING:tensorflow:From C:\Users\24762\PycharmProjects\pythonProject2\main.py:6: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-11-21 11:10:23.065778: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 9458 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 4070, pci bus id: 0000:01:00.0, compute capability: 8.9

Process finished with exit code 0
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

怡步晓心l

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值