解决:运行 tensorflow-gpu相关代码报错/缺少dll文件(无需修改tensorflow版本)

一、问题

在运行以下一些代码测试 gpu的时候报错了

# 代码1
print(tf.test.is_gpu_available())
# 代码2
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

有如下的错误提示,在代码1中,gpu启动为false

2021-08-20 12:44:12.846291: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cusolver64_10.dll'; dlerror: cusolver64_10.dll not found

2021-08-20 12:42:42.534915: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

二、解决

1、下载dll

到链接里下载

https://pan.baidu.com/s/1kFGzdhhakMP4irRaXHUVnw

提取码:kfll

2、移动

放置在 C:\Windows\System 文件夹下

3、测试

再次运行代码

print(tf.test.is_gpu_available())

发现最终结果为True了

解决:运行 tensorflow-gpu相关代码报错/缺少dll文件(无需修改tensorflow版本)_第1张图片

参考链接:

tensorflow-gpu版本使用时报错,各种dll文件找不到

你可能感兴趣的:(TensorFlow入门,tensorflow,python)