MikA
MikA

Reputation: 5582

R Foreach behavior different in Windows and Linux

My R script which uses libraries doSNOW and foreach to run a process in parallel. This script works properly and uses all cores available in a Windows 7 machine( 4 cores in my case). but when it runs on a Linux (redhat) machine which has 24 cores it makes use of only 3 cores. is there anything I have to take care in the R script while running on a Linux machine?

Upvotes: 0

Views: 299

Answers (2)

Hong Ooi
Hong Ooi

Reputation: 57697

You've probably got a hard-coded makeCluster(3) in your startup code. Change it to makeCluster(detectCores()) or makeCluster(detectCores()-1). (The -1 is so you'll always have a spare core for other tasks.)

Upvotes: 2

Brent
Brent

Reputation: 131

Use the parallel backend doMC in Linux.

Upvotes: 0

Related Questions