Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain the number of CPU cores in Julia

I want to obtain the number of cores available in Julia. Currently I am doing the following:

using PyCall
@pyimport psutil
nCores = psutil.cpu_count()

This calls a Python function. I would like, however, to use some Julia procedure. How can it be done?

like image 841
Pablo Avatar asked Jan 13 '15 20:01

Pablo


People also ask

How do I check number of CPU cores?

Press Ctrl + Shift + Esc to open Task Manager. Select the Performance tab to see how many cores and logical processors your PC has.

How do I know how many cores available on my instance?

To view the CPU options for an instance using the console In the left navigation pane, choose Instances and select the instance. On the Details tab, under Host and placement group, find Number of vCPUs. To view core count and threads per core, choose the value for Number of vCPUs.

How do I select the number of processors?

Core Settings In Windows 10Type 'msconfig' into the Windows Search Box and hit Enter. Select the Boot tab and then Advanced options. Check the box next to Number of processors and select the number of cores you want to use (probably 1, if you are having compatibility issues) from the menu. Select OK and then Apply.

What is number of core per processor?

Conclusion. When buying a new computer, whether a desktop PC or laptop, it's important to know the number of cores in the processor. Most users are well served with 2 or 4 cores, but video editors, engineers, data analysts, and others in similar fields will want at least 6 cores.


2 Answers

Sys.CPU_CORES is not defined in Julia v1.1.0. However, the following does the job.

length(Sys.cpu_info())
like image 66
Ciarán O'Mara Avatar answered Sep 29 '22 02:09

Ciarán O'Mara


According to the documentation, the "number of cores available" can be limited by the JULIA_NUM_THREADS environment variable.

To see the number of threads available to Julia, use

Threads.nthreads()
like image 33
RikH Avatar answered Sep 29 '22 02:09

RikH