5
$\begingroup$

I have a piece of code which looks like this:

ParallelTable[

  Monitor[
    Table[
    <code here>
    ,{i,i1,i2];
  ,i];

]

so basically a Table which I parallelize. Each element of this parallelized table being itself a Table which I want to monitor.

I receive this error message:

FrontEndObject::notavail: A front end is not available; certain operations require a front end.

This error originates from the Monitor[]. I suspect that because my first Table is parallelized, somehow the dynamic cell into which Monitor[] will write to is not connected to any Front End or something...

How would I solve this issue?

$\endgroup$
6
  • $\begingroup$ What happened when you started a front end? $\endgroup$ Jul 3, 2014 at 10:49
  • $\begingroup$ from help, it says: generates a monitor cell that shows the continually updated current value...In a notebook, the monitor cell normally appears directly after the cell in which Monitor[expr,mon] is evaluated so clearly Monitor requires a frontend. Can't be used in script/batch. $\endgroup$
    – Nasser
    Jul 3, 2014 at 11:28
  • $\begingroup$ @OleksandrR. Can you start a front end for each parallel kernel and use Monitor? $\endgroup$
    – acl
    Jul 3, 2014 at 11:46
  • $\begingroup$ In case it is not clear, I have a Front End running for my master kernel. How would I start a Front End for each child kernels ? $\endgroup$
    – coussin
    Jul 3, 2014 at 13:22
  • $\begingroup$ Or rather, each child kernels should use the Front End used by my master kernel... $\endgroup$
    – coussin
    Jul 3, 2014 at 13:33

1 Answer 1

3
$\begingroup$

As pointed in the comments by @Nasser, Monitor needs a front end, so it should be outside ParallelTable. It also needs a variable that acts as a "counter" and that is shared among all the kernels participating in the calculation, for that you can use SetSharedVariable. Therefore, a solution to your question would be:

SetSharedVariable[iter]
iter = 0
Monitor[
  ParallelTable[ 
   iter += 1;
   FactorInteger[999999999]
   , {1000}
   ], ProgressIndicator[iter, {0, 1000}]];

Its is true that its questionable if the cost of keeping the iteration counter updated makes parallelism worthwhile, as pointed by @mfvonh. This should be evaluated case by case, and its not impossible that its advantageous. I have found this trick useful at least once.

$\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.