简体   繁体   English

像 Colab 和 Kaggle 一样,在 Google Cloud VM Notebooks 中制作简单的循环使用 100% 的 CPU

[英]Make simple loop utilizes 100% of CPU in Google Cloud VM Notebooks just like on Colab and Kaggle

for i in range(1,1000000000):
  i=i+1

When this simple loop is running of Kaggle/Colab, 100% of CPU will be taken.当这个简单的循环运行 Kaggle/Colab 时,将占用 100% 的 CPU。 So I guess there are some multithread optimizing features on Colab to utilize every core of the CPU in running loops (which could be right or wrong).所以我猜想 Colab 上有一些多线程优化功能可以在运行循环中利用 CPU 的每个内核(这可能是对的,也可能是错的)。

However, while running the GCP counterpart, the simple loop only takes 25% of the CPU, which is only one of the four cores of mine.然而,在运行 GCP 对应项时,简单循环仅占用 25% 的 CPU,这只是我的四个核心之一。 My spec is 4v C2 computing optimized CPU with 16GB ram.我的规格是具有 16GB 内存的 4v C2 计算优化 CPU。

How to make use of 100% CPU on GCP?如何在 GCP 上使用 100% CPU?

Higher-priority tasks are in general going to be executed ahead of lower-priority tasks.较高优先级的任务通常会在较低优先级的任务之前执行。 Cloud Spanner allows high-priority tasks to utilize up to 100% of the available CPU resources even if there are competing lower-priority tasks. Cloud Spanner 允许高优先级任务利用高达 100% 的可用 CPU 资源,即使存在竞争的低优先级任务也是如此。 While lower-priority system tasks can be delayed in the short term, they must run eventually.虽然较低优先级的系统任务可以在短期内延迟,但它们最终必须运行。 Therefore, you must provision your instance with enough compute capacity to handle all tasks.因此,您必须为您的实例提供足够的计算能力来处理所有任务。

Example: You have 8 cores on your instance your overall usage would be 100% / 8 = 12.5% per core (It may vary depending on tasks).示例:您的实例上有 8 个核心,您的总体使用率为 100% / 8 = 12.5% 每个核心(可能因任务而异)。

So maintaining less core give you more utilizations因此,保持更少的核心可以让您获得更多的利用率

Using 100% may cause VM shutdown.使用 100% 可能会导致 VM 关闭。 Try to make more cores so that each core will give you more utilization.尝试制造更多核心,以便每个核心都能为您提供更多利用率。

For more info follow CPU utilization and task priority .有关更多信息,请关注CPU 利用率和任务优先级

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

相关问题 json 格式的 python 谷歌云列表 vm - python google cloud list vm in json format google colab 与 google 云存储数据出口 - google colab with google cloud storage data egress 如何将数据从 Google Cloud VM 迁移到 Google Kube.netes Engine? - How to migrate data from Google Cloud VM to Google Kubernetes Engine? 仅由一个 DAG 访问的 Google Cloud Secret - Google Cloud Secret accessed by just one DAG 如何自动按计划运行 Google Cloud 的“AI Notebooks”? - How can I run Google Cloud's "AI Notebooks" on a schedule automatically? 如何将 React 应用程序部署到 Google Cloud Vm 实例? - How to deploy React app to Google Cloud Vm Instance? 无法 SSH 进入我在 Google Cloud 上的 Compute Engine 虚拟机实例 - Unable to SSH into my Compute Engine VM instance on Google Cloud 如何自动创建 1500 个 Google Cloud VM 实例? - How to automate creating 1500 Google Cloud VM Instances? Terraform 中的 Google Cloud VM 自动缩放 - 更新映像 - Google Cloud VM Autoscaling in Terraform - Updating Images 在 Google Cloud 上使用 Jenkins 启动现有的 VM - Starting already existing VM with Jenkins on Google Cloud
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM