Tensorflow安装后出现的问题

在Tensorflow安装完成后,为了检查是否安装成功时出现以下问题

(tf_gpu) C:\Users\1789834715>python
Python 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import tensorflow as tf
2021-10-31 22:15:07.684721: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found
2021-10-31 22:15:07.685291: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.

a = tf.constant([[1,2],[3,4]])
2021-10-31 22:15:54.077757: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found
2021-10-31 22:15:54.078762: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cublas64_11.dll’; dlerror: cublas64_11.dll not found
2021-10-31 22:15:54.079701: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cublasLt64_11.dll’; dlerror: cublasLt64_11.dll not found
2021-10-31 22:15:54.080633: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cufft64_10.dll’; dlerror: cufft64_10.dll not found
2021-10-31 22:15:54.081430: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘curand64_10.dll’; dlerror: curand64_10.dll not found
2021-10-31 22:15:54.082382: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cusolver64_11.dll’; dlerror: cusolver64_11.dll not found
2021-10-31 22:15:54.083534: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cusparse64_11.dll’; dlerror: cusparse64_11.dll not found
2021-10-31 22:15:54.084505: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudnn64_8.dll’; dlerror: cudnn64_8.dll not found
2021-10-31 22:15:54.084690: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1835] 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…

2021-10-31 22:15:54.090138: I tensorflow/core/platform/cpu_feature_guard.cc:142] 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.

a = tf.constant([[1,2],[3,4]])
b = tf.constant([[5,6],[7,8]])
c = tf.matmul(a,b)
print(c)
tf.Tensor(
[[19 22]
[43 50]], shape=(2, 2), dtype=int32)

从以上报错中,可以发现,在安装TENSORFLOW时,有很多使用GPU需要的库没有安装。

然后我运行了下面的代码查看了tensorflow的版本,以及GPU能否使用,结果如下:

import tensorflow as tf
import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL’]=’2′
print(tf.version)
2.6.0
a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)
tf.Tensor(3.0, shape=(), dtype=float32)
print(‘GPU:’, tf.test.is_gpu_available())
WARNING:tensorflow:From

为了解决以上问题,我们需要更换安装的tensorflow版本,或者下载缺失的库:

这里我只下载了 cudart64_110.dll ,可以在这个网站上免费下载 免费下载缺失的 DLL 文件 | DLL‑files.com (dll-files.com)

因为没有找到其他缺失的库,我就没有下载了,直接将下载好的库放在路径D:\Anaconda3\envs\tf_gpu\Library\bin(根据自己存放的位置而定)

运行结果如下

import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
print(tf.__version__)
a = tf.constant(1.)
b = tf.constant(2.)
print(a+b)
print('GPU:', tf.test.is_gpu_available())

Tensorflow安装后出现的问题

查看到自己的GPU信息,说明安装成功,只是缺少的库还没有添加,这个只能后续添加了。

Original: https://blog.csdn.net/weixin_44881806/article/details/121071289
Author: 骨灰小鱼人提莫
Title: Tensorflow安装后出现的问题

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496817/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球