RuntimeError:另一个循环正在运行时无法运行事件循环
试图在我的本地设置tensorflow_federated。所有导入版本都是正确的:
CUDA = 10.1,
python = 3.6.9,
tensorflow = 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
答案 0 :(得分:0)
尝试删除import nest-asyncio
答案 1 :(得分:0)
在 Mac OS 上将 tensorflow-federated tutorial code 复制+粘贴到本地 Jupyter 笔记本时,我遇到了非常类似的错误。除了 nest_asyncio
和 tf
之外,我还通过导入和应用 tff
解决了这个问题:
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
的某种组合,以该顺序)。>