9
$\begingroup$

I know that the command LaunchKernels[] starts up four kernels on my machine:

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

I also figured out that the command SetOptions[EvaluationNotebook[], Evaluator -> "xyz"]; should then set the given Notebook to be evaluated on some kernel "xyz", but I cannot find the right syntax for this "xyz" to refer to for instance KernelObject[1, "local"]. What should I write there?

EDIT

This is the relevant command: FrontEndExecute[FrontEndToken["ModifyEvaluatorNames"]]. Create a couple Kernel names and evaluate in parallel.

$\endgroup$
1

2 Answers 2

12
$\begingroup$

LaunchKernels launches subkernels used for parallel calculations. These are not meant to and cannot be set to as the evaluator for a notebook.

To set the evaluator for a notebook, use Evaluation -> Kernel Configuration Options to set up a new kernel, then use Evaluation -> Notebook's Kernel to assign it to the current notebook.

$\endgroup$
3
  • 4
    $\begingroup$ Can I automatically have Mathematica start a Kernel for each Notebook? I don't like the "everything is shared" approach of Mathematica, so I would love to have a distinct Kernel + Context for each Notebook by default. $\endgroup$ Commented Sep 1, 2015 at 9:58
  • 1
    $\begingroup$ @ThomasFankhauser I wouldn't bother. Usually licenses allow running only a limited number of kernels, which would set a limit on this. Within that limit, it would be possible to hack something together, but I'm not sure it's worth it as I don't find this type of workflow useful. If you ask a question someone might get interested and write an answer about how to hack it together. Do take a look at using notebook-specific contexts, which create the illusion of localization within notebooks, but use the same kernel. $\endgroup$
    – Szabolcs
    Commented Sep 1, 2015 at 10:35
  • 4
    $\begingroup$ Okay thanks for your response. Coming from programming, it's just very unusual to clutter everything together, where you need to wait for evaluations in different notebooks. I think, for sharing the package system should be used and not more. But thanks, you helped me! $\endgroup$ Commented Sep 1, 2015 at 11:07
0
$\begingroup$

@ThomasFankhauser

Having all notebooks share all variables can cause subtle problems. I don't know why this is the default and don't see how to change it, but you can change on a per-notebook basis. With the notebook open, go to menu

Evaluation / Notebook's Default Context / Unique to this Notebook (instead of Global)

$\endgroup$
1
  • 1
    $\begingroup$ The Way Mathematica does it not easy. I asked about a global option to have different Kernel launch by default each time a new notebook is opened. see this question. But no answer. I find Maple's way much much simpler and easier here than how Mathematica does it. In Maple, I set this option once and forget about it. $\endgroup$
    – Nasser
    Commented Jul 3 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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