【问题标题】:I have this error when trying to run TensorBoard: ImportError: cannot import name 'parameter_server_strategy_v2' from 'tensorflow.python.distribute'尝试运行 TensorBoard 时出现此错误:ImportError: cannot import name 'parameter_server_strategy_v2' from 'tensorflow.python.distribute'
【发布时间】:2021-05-13 14:38:54
【问题描述】:

我想使用 tensorboard 但收到此错误:

ImportError: cannot import name 'parameter_server_strategy_v2' from 'tensorflow.python.distribute' (C:\Users\Connor Lab\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\distribute\__init__.py)

我正在使用 keras 回调。代码如下:

model = [...]
logdir = os.path.join(os.curdir, "my_dir")
t_callback = TensorBoard(log_dir = logdir,histogram_freq=1)
model.fit(x, y, epochs=100, steps_per_epoch=50, callbacks=[t_callback], validation_data=val_data)

我在 Windows 10 上,使用 Anaconda 运行 TensorFlow-gpu, 蟒蛇3.7, 张量流(-gpu)版本是 2.3.0, 张量板 2.30 版

关于如何修复它的任何想法?

我在 Pycharm 和 Jupiter 上都试过了,同样的错误

完全错误

(gputest) C:\PycharmProjects\pythonProject\Learning>tensorboard --logdir=my_dir
2021-02-09 16:52:16.003796: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
Traceback (most recent call last):
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\Scripts\tensorboard-script.py", line 5, in <module>
    from tensorboard.main import run_main
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorboard\main.py", line 43, in <module>
    from tensorboard import default
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorboard\default.py", line 40, in <module>
    from tensorboard.plugins.beholder import beholder_plugin_loader
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorboard\plugins\beholder\__init__.py", line 22, in <module>
    from tensorboard.plugins.beholder.beholder import Beholder
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorboard\plugins\beholder\beholder.py", line 225, in <module>
    class BeholderHook(tf.estimator.SessionRunHook):
  File "C:\Users\Connor Lab\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__
    module = self._load()
  File "C:\Users\Connor Lab\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\util\lazy_loader.py", line 45, in _load
    module = importlib.import_module(self.__name__)
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1 import estimator
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\_api\v1\estimator\__init__.py", line 10, in <module>
    from tensorflow_estimator._api.v1.estimator import experimental
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\_api\v1\estimator\experimental\__init__.py", line 10, in <module>
    from tensorflow_estimator.python.estimator.canned.dnn import dnn_logit_fn_builder
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\python\estimator\canned\dnn.py", line 31, in <module>
    from tensorflow_estimator.python.estimator import estimator
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py", line 52, in <module>
    from tensorflow_estimator.python.estimator import run_config
  File "C:\Users\Connor Lab\anaconda3\envs\gputest\lib\site-packages\tensorflow_estimator\python\estimator\run_config.py", line 30, in <module>
    from tensorflow.python.distribute import parameter_server_strategy_v2
ImportError: cannot import name 'parameter_server_strategy_v2' from 'tensorflow.python.distribute' (C:\Users\Connor Lab\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\distribute\__init__.py)

【问题讨论】:

  • this 回答你的问题了吗?

标签: python tensorflow keras tensorflow2.0 tensorboard


【解决方案1】:

你可以试试这个;

pip install --upgrade tensorflow-estimator==2.3.0

【讨论】:

  • 请在您的回答中添加一些解释
猜你喜欢
  • 2021-10-22
  • 2021-01-09
  • 2021-03-11
  • 1970-01-01
  • 2022-08-15
  • 2019-07-20
  • 2020-07-16
  • 2019-06-10
  • 2014-09-25
相关资源
最近更新 更多