3
$\begingroup$

My Laptop only has two cores,

In[69]:= $ProcessorCount

Out[69]= 2

And

In[66]:= $ConfiguredKernels

Out[66]= {<<2 local kernels>>}

But if I run this

In[1]:= LaunchKernels[10]

Out[1]= {"KernelObject"[1, "local"], "KernelObject"[2, "local"], 
 "KernelObject"[3, "local"], "KernelObject"[4, "local"], 
 "KernelObject"[5, "local"], "KernelObject"[6, "local"], 
 "KernelObject"[7, "local"], "KernelObject"[8, "local"], 
 "KernelObject"[9, "local"], "KernelObject"[10, "local"]}

What does those Kernel objects mean?

$\endgroup$
  • $\begingroup$ My assumption would be that the kernels are essentially behaving as separate contexts, and that everything functions as normal until you try to make more than 2 kernels perform lengthy operations. At that point, it's likely the work each kernel needs to do is scheduled to your CPU resources however the OS sees fit. $\endgroup$ – IPoiler Nov 18 '15 at 1:18
  • $\begingroup$ Related: mathematica.stackexchange.com/q/38979/18476 $\endgroup$ – Karsten 7. Nov 18 '15 at 7:04
  • $\begingroup$ You can launch as many kernels as your license allows. The number of cores your CPU has does not limit this at all. Typically, launching more kernels than the number of cores will make parallel calculations slower, so it's probably not a good idea to do this. But it is definitely possible. Just as you can run more than two programs at the same time, you can run more than two Mathematica kernels at the same times. $\endgroup$ – Szabolcs Nov 18 '15 at 11:34
4
$\begingroup$

LaunchKernels launches kernel processes; i.e., OS processes running copies of the Mathematica kernel. It returns a list of tokens that can be used to refer to any of these processes afterward; for example:

$ProcessorCount

4

$KernelCount

0

ko = LaunchKernels[]

{"KernelObject"[1, "local"], "KernelObject"[2, "local"], "KernelObject"[3, "local"], "KernelObject"[4, "local"]}

$KernelCount

4

CloseKernels[ko[[4]]]

"KernelObject"[4, "local", "<defunct>"]

Kernels[]
{"KernelObject"[1, "local"], "KernelObject"[2, "local"], 
 "KernelObject"[3, "local"]}

It really has nothing directly to do with how many CPU cores your computer has, except the number of cores seems to determine the default number of kernels launched when you call LaunchKernels with no argument.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.