简体   繁体   中英

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. 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).

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. My spec is 4v C2 computing optimized CPU with 16GB ram.

How to make use of 100% CPU on GCP?

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. 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).

So maintaining less core give you more utilizations

Using 100% may cause VM shutdown. Try to make more cores so that each core will give you more utilization.

For more info follow CPU utilization and task priority .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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