Detect the number of cores on windows

10,217

Solution 1

The parallel package now has a function to detect the number of cores: parallel:::detectCores().

Solution 2

This thread has a number of suggestions, including:

Sys.getenv('NUMBER_OF_PROCESSORS')

Note also the posting in that thread by Prof. Ripley which talks to the difficulties of doing this.

Solution 3

If you actually need to distinguish between actual cores, chips, and logical processors, the API to call is GetLogicalProcessInformation

GetSystemInfo if just want to know how many logical processors on a machine (with no differentiation for hyperthreading.).

How you call this from "R" is beyond me. But I'd guess R has a facility for invoking code from native Windows DLLs.

Share:
10,217
Zach
Author by

Zach

Interested in Data Science?? I currently teach 2 online classes through DataCamp. Check them out to learn more: Advanced Deep Learning with Keras in Python The Machine Learning Toolbox - R

Updated on June 14, 2022

Comments

  • Zach
    Zach almost 2 years

    If I am running R on linux or on a mac, I can detect the number of available cores using multicore:::detectCores(). However, there's no windows version of the multicore functions, so I can't use this technique on windows.

    How can I programmatically detect the number of cores on a windows machine, from within R?