本文介绍了Tensorflow 2.4.0 导入错误无法导入名称 'multi_worker_mirrored_2x1_cpu'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Python 中加载 tensorflow==2.4.0 时出现错误.我试过卸载并恢复到早期版本(但仍然是 2),但似乎无法解决它.有人知道吗?完整的错误是:

I'm getting an error upon loading tensorflow==2.4.0 in Python. I've tried uninstall and reverting to an earlier version (but still 2), but can't seem to be able to solve it. Anyone any idea? The full error is:

  File "<stdin>", line 1, in <module>
  File "C:\Users\CX667CJ\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 49, in <module>
    from ._api.v2 import __internal__
  File "C:\Users\CX667CJ\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\__internal__\__init__.py", line 11, in <module>
    from . import distribute
  File "C:\Users\CX667CJ\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\__internal__\distribute\__init__.py", line 10, in <module>
    from . import combinations
  File "C:\Users\CX667CJ\AppData\Roaming\Python\Python38\site-packages\tensorflow\_api\v2\__internal__\distribute\combinations\__init__.py", line 20, in <module>
    from tensorflow.python.distribute.strategy_combinations import multi_worker_mirrored_2x1_cpu
ImportError: cannot import name 'multi_worker_mirrored_2x1_cpu' from 'tensorflow.python.distribute.strategy_combinations' (C:\Users\CX667CJ\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\distribute\strategy_combinations.py)```

推荐答案

我今天看到了类似的问题

I saw similar issue today

从 tensorflow.python.distribute.strategy_combinations 导入multi_worker_mirrored_2x1_cpu 导入错误:无法导入名称'multi_worker_mirrored_2x1_cpu' 来自'tensorflow.python.distribute.strategy_combinations'(C:\Users\sharm\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\distribute\strategy_combinations.py)

我检查了文件,但找不到multi_worker_mirrored_2x1_cpu".在 git 上查看 tensorflow repo.该文件存在于那里.所以我考虑重新安装 tensorflow(如果不这样做,请使用 virtualenv),关闭我的程序并重新启动一切.我现在不再遇到这个问题了.

I checked out the file and could not locate 'multi_worker_mirrored_2x1_cpu'.Looked into tensorflow repo on git. this file was present there.So I considered reinstalling tensorflow (use virtualenv if you don't), closed my program and restarted everything. I no longer got this issue now.

还要考虑,

pip3 install --upgrade tensorflow-gpu --user

版本 = 2.4.1

如果这也能解决您的问题,请告诉我.

Let me know if this resolves your issue as well.

这篇关于Tensorflow 2.4.0 导入错误无法导入名称 &amp;#39;multi_worker_mirrored_2x1_cpu&amp;#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:16