I wish to run a few notebooks (with distinct contexts) at once using MMA 10 on Windows 8.1. I wish to run at least one of the notebooks interactively, adding and executing lines of code. If another notebook needs attention, perhaps by opening a dialog box, I need to be able to open that window, respond, and then return to the notebook in which I was doing code development. How do I accomplish this?
2 Answers
You can use several Mathematica kernels for this purpose.
Go to Evalution -> Kernel Configuration Options. In this menu you can add new kernels.
After in notebook, you can specify which kernel it must use by Evaluation -> Notebook's kernel.
Usually, I use two local Mathematica kernels. When default one is doing some number crunching, in other notebook, which I want to run interactively, I use the other (not busy) kernel.
-
$\begingroup$ ,@Kuba, I have four processor cores and a license that accommodates four kernels. My "number crunching" notebook wishes to use all available kernels at times. If I start my "interactive" notebook before starting my "number crunching" notebook and use the procedure described in the Answer above, will the "number crunching" notebook use just the three remaining kernels, or do something else? $\endgroup$ Commented Nov 30, 2014 at 12:40
-
1$\begingroup$ @bbgodfrey (If your comment is addressed to me.) Unfortunately, I'm not a specialist here, but I suppose no. Parallel code uses parallel procedures (like ParallelMap) and they, in turn, use subkernels. Creating new kernel, as I described, will create new instance of Mathematica kernel, having nothing in common with other instances and their subkernels, which are used for parallel work. Therefore, I think no. $\endgroup$– ktmCommented Nov 30, 2014 at 12:58
-
1$\begingroup$ Thanks for the effective solution, which I have verified. I also verified that each notebook opens its own set of kernels and, if running parallel computations, tries to claim all four cores on my computer. Although the "number cruncher" notebook slowed a bit, nothing bad happened. In all. 12 kernels were open. $\endgroup$ Commented Dec 1, 2014 at 13:12
-
$\begingroup$ The different kernels do not share variables, right? $\endgroup$– a06eCommented Jul 11, 2017 at 10:21
-
1$\begingroup$ @becko That's right. Using two different kernels is like using several Mathematica instances, like mentioned in answer by UnchartedWorks. $\endgroup$– ktmCommented Jul 12, 2017 at 8:40
For Mac users, you can use the command below to launch the second Mathematica instance. So you could run two Mathematica instances.Then you can open different notebooks in different Mathematica instances.
open -n /Applications/Mathematica.app
-
1$\begingroup$ The same can be done in Linux by simply executing
mathematica
in terminal several times. If you want to use the existing instance of Mathematica (if there is any), usemathematica -sl
(mathematica --singlelaunch
) instead. $\endgroup$– ktmCommented Jul 12, 2017 at 8:45 -
3$\begingroup$ The same can be done in Windows: press the [SHIFT] key while clicking on the Mathematica icon to start a new instance, which can run in parallel to other previously running ones. $\endgroup$– divenexCommented May 12, 2019 at 17:52