[英]How to get number of threads supported by CPU which can do hyper-threading?
My AMD CPU has 8 cores and with hyper-threading, can support up to 8 threads.我的 AMD CPU 有 8 个内核,并且具有超线程,最多可以支持 8 个线程。
How do I get the number threads that can be supported by a CPU in python?如何获取 python 中 CPU 可以支持的线程数? I know how to get number of cores(see code below) but don't know how to get number of threads.
我知道如何获取内核数(请参见下面的代码),但不知道如何获取线程数。
import multiprocessing
multiprocessing.cpu_count()
I am using windows 10, python 3.7.我正在使用 windows 10、python 3.7。
EDIT: multiprocessing.cpu_count()
is right answer.编辑:
multiprocessing.cpu_count()
是正确答案。 It includes the effects of hyper-threading.它包括超线程的效果。
I will answer my own question.我会回答我自己的问题。 The answer is already in the question.
答案已经在问题中。
multiprocessing.cpu_count()
returns the number of CPU threads supported by the CPU and this number includes the effects of hyper-threading. multiprocessing.cpu_count()
返回 CPU 支持的 CPU 线程数,这个数字包括超线程的影响。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.