Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run multicore on a macbook pro with 2 cores?

Tags:

r

multicore

So this bit of code:

library(plyr)
library(doMC) 
registerDoMC(cores=2) 
x=1:100
llply(x, some_function, .parallel=TRUE)

fails with an error like so:

__THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__ ()

the error disappears when I run R from terminal. So it's something about the GUI that breaks it. Unfortunately, I share this code with collaborators and so I can't ask them to run it from the terminal. This forum post says It looks as if this problem w/ the doMC backend was coming from my having been sourcing the "/Applications/R.app/Contents/Resources/GUI- tools.R" but I am not intentionally doing that in R.app. Is there any way to turn off this conflicting behavior?

My Mac specs: Also running R GUI 2.13.1. OSX 10.7.1, doMC Version 1.2.3 with 64bit R.app. Also have a MB Pro 2.53 with Intel Core 2 Duo

like image 458
Maiasaura Avatar asked Nov 14 '22 16:11

Maiasaura


1 Answers

Ask on R-SIG-Mac if you want real answers ;). This has nothing to do with the GUI tools, it has to do with the Cocoa running event loop in the children - see ?multicore for the warning about GUIs. You may want to update to more recent multicore which disables the event loop in the GUI (if possible). Also avoid any Quartz graphics calls in the code you run.

like image 158
Simon Urbanek Avatar answered Nov 16 '22 18:11

Simon Urbanek