【问题标题】:Cannot run the event loop when another loop is running当另一个循环正在运行时无法运行事件循环
【发布时间】:2020-06-09 00:28:59
【问题描述】:

RuntimeError: 在另一个循环正在运行时无法运行事件循环

尝试在我的本地设置 tensorflow_federated。所有导入版本都是正确的:

CUDA = 10.1,

python = 3.6.9,

张量流 = 2.2.0,

tf_federated = 最新

Google Colab 中没有发生此错误。但是,当我尝试进行任何联合计算时,会发生在我的本地机器上。我收到运行时错误: RuntimeError: 在另一个循环正在运行时无法运行事件循环

RuntimeError                              Traceback (most recent call last)
<ipython-input-5-9c097e9baec9> in <module>
----> 1 tff.federated_computation(lambda: 'hi')()

~\AppData\Local\Continuum\anaconda3\envs\tflocal\lib\asyncio\base_events.py in run_forever(self)
    426         if events._get_running_loop() is not None:
    427             raise RuntimeError(
--> 428                 'Cannot run the event loop while another loop is running')
    429         self._set_coroutine_wrapper(self._debug)
    430         self._thread_id = threading.get_ident()

RuntimeError: Cannot run the event loop while another loop is running

【问题讨论】:

标签: tensorflow tensorflow2.0 tensorflow-serving tensorflow-federated


【解决方案1】:

尝试删除import nest-asyncio

【讨论】:

【解决方案2】:

在 Mac OS 上将tensorflow-federated tutorial code 复制+粘贴到本地 Jupyter 笔记本时,我遇到了一个非常相似的错误。除了tf和tff之外,我还通过导入和应用nest_asyncio解决了这个问题:

import tensorflow as tf
import tensorflow_federated as tff
import nest_asyncio
nest_asyncio.apply()

...正如 OP 在上面的评论中链接的单独 tensorflow github tutorial 的 步骤 2 中所建议的那样。第 1 步根本没有帮助我(而且我怀疑这对那些已经设法安装 tensorflow_federated 的人有很大帮助,例如按顺序使用 conda 和 pip 的某种组合)。

【讨论】:

  • 如果有帮助,我安装了:conda create -n tff jupyter tensorflow;conda activate tff;pip install --upgrade tensorflow-federated;。这带来了nest_asyncio,这就是为什么上面链接的 GitHub 页面的第 1 步对我没有帮助。
猜你喜欢
  • 1970-01-01
  • 2017-02-06
  • 1970-01-01
  • 2020-06-23
  • 2021-06-11
  • 2022-10-30
  • 2022-11-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多