TensorFlow 不起作用

Posted

技术标签:

【中文标题】TensorFlow 不起作用【英文标题】:TensorFlow doesn't works 【发布时间】:2021-04-10 12:23:18 【问题描述】:

我必须在我正在做的课程中使用 tensorflow,所以我尝试安装它,但结果总是错误。我尝试了不同的方法,我离安装 tensorflow 越近是通过将 Anaconda Navigator 中左上角的“Applications on”按钮更改为 tf.结果是下一个

import tensorflow as tf

2021-01-04 14:36:46.204862: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-01-04 14:36:46.205115: 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.
Traceback (most recent call last):

  File "<ipython-input-1-64156d691fe5>", line 1, in <module>
    import tensorflow as tf

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 55, in <module>
    from ._api.v2 import compat

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\__init__.py", line 39, in <module>
    from . import v1

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\__init__.py", line 34, in <module>
    from . import compat

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\compat\__init__.py", line 39, in <module>
    from . import v1

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\compat\v1\__init__.py", line 51, in <module>
    from tensorflow._api.v2.compat.v1 import lite

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\lite\__init__.py", line 11, in <module>
    from . import experimental

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\__init__.py", line 10, in <module>
    from . import nn

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\nn\__init__.py", line 10, in <module>
    from tensorflow.lite.python.lite import TFLiteLSTMCell

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\lite\python\lite.py", line 40, in <module>
    from tensorflow.lite.python.convert import build_toco_convert_protos  # pylint: disable=unused-import

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\lite\python\convert.py", line 33, in <module>
    from tensorflow.lite.python import util

  File "C:\Users\marioc\AppData\Roaming\Python\Python38\site-packages\tensorflow\lite\python\util.py", line 30, in <module>
    import flatbuffers

ModuleNotFoundError: No module named 'flatbuffers'

顺便说一下,我正在使用 Spyder 4.1.5 和 python 3.8.5 64 位

有人知道如何解决这个问题吗?我会非常感谢你的帮助。谢谢!

【问题讨论】:

您可以通过 pip install flatbuffers 安装它,请记住,您是在相同的环境中安装,而对于 conda 环境,您必须执行 conda install -c conda-forge python-flatbuffers 你需要安装flatbuffers,因为你使用的是anaconda:conda install -c conda-forge flatbuffers 【参考方案1】:

如果您使用的是 Windows,请尝试安装:

VC_redist.x64.exe

【讨论】:

现在我得到下一个错误:W tensorflow/stream_executor/platform/default/dso_loader.cc:60] 无法加载动态库 'cudart64_110.dll'; dlerror: 找不到 cudart64_110.dll ***.com/questions/59823283/…

以上是关于TensorFlow 不起作用的主要内容,如果未能解决你的问题,请参考以下文章

TensorFlow 数据集拆分不起作用

TensorFlow-Lite 预训练模型在 Android 演示中不起作用

Tensorflow:Int,float类型在record_defaults中不起作用

univariate_data 函数在 python tensorflow 教程(熊猫数据框)中不起作用

使用基本的低级 TensorFlow 训练循环训练 tf.keras 模型不起作用

from __future__ import absolute_import as _absolute_import 错误,tensorflow 不起作用