简体   繁体   English

在 Colab 中同时运行多个单元

[英]Run multiple cells in Colab at the same time

I have been searched the answer for a while.我已经搜索了一段时间的答案。 The answers include using Ipyparallel , but there are no clear instructions on how can I do to apply to two cells in general.答案包括使用Ipyparallel ,但没有明确说明我如何才能将其应用于一般的两个单元格。 Most of the examples are just compute some value with some functions distributively.大多数示例只是用一些函数分布地计算一些值。 They are at least not clear for me to understand how to solve the problem.他们至少对我来说不清楚如何解决这个问题。 I wish someone could provide some code or instructions on how can I do for running two independent cells in general on Colab.我希望有人可以提供一些代码或说明,说明如何在 Colab 上运行两个独立的单元。 Or, if there are other methods, it is also fine as long as it works.或者,如果有其他方法,只要有效,也可以。 Thank you.谢谢你。

It's not exactly straightforward, because Python is synchronous by default.这并不简单,因为 Python 默认是同步的。 Maybe encapsulating your cells in functions and using asyncio to execute two functions asynchronously will do the job.也许将您的单元格封装在函数中并使用asyncio异步执行两个函数将完成这项工作。 Or, if it includes something like heavy processing, threading or multiprocessing modules may be the way to go.或者,如果它包含诸如重处理之类的东西, threading或多multiprocessing模块可能是 go 的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM