[R] snow: cluster initialization

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 18 15:30:49 CEST 2013


On 18/04/2013 14:22, Kaiyin Zhong (Victor Chung) wrote:
> Thanks.
> So is there a way to get the number of cpu cores in R?

Yes, for various definitions of 'core'.  Try ??cores which gets you to

parallel::detectCores   Detect the Number of CPU Cores


And BTW 'snow' is not part of R.


>
>
> Best regards,
>
> Kaiyin ZHONG
> ------------------------------
> FMB, Erasmus MC
> k.zhong at erasmusmc.nl
> kindlychung at gmail.com
>
>
> On Thu, Apr 18, 2013 at 3:18 PM, Jon Olav Skoien <
> jon.skoien at jrc.ec.europa.eu> wrote:
>
>> I also wanted to add the result from my Windows machine (R 3.0.0) to the
>> answer below:
>>
>>
>>> ncore = system('nproc')
>>> ncore
>> [1] 127
>> # My machine was not happy about starting a cluster with 127 nodes though.
>>
>> Best wishes,
>> Jon
>>
>>
>> On 18-Apr-13 15:13, Jon Olav Skoien wrote:
>>
>>> I dont think this has anything to do with the snow package, you should
>>> rather start by checking what is the output of system('nproc') is on your
>>> computer, and also whether it is possible to assign this to a variable. I
>>> tried on a redhat linux (R 2.15.0) server:
>>>
>>>> ncore = system('nproc')
>>> 16
>>>> ncore
>>> [1] 0
>>> # the result is printed, not returned
>>>
>>>
>>> Best wishes,
>>> Jon
>>>
>>> On 18-Apr-13 10:52, Kaiyin Zhong (Victor Chung) wrote:
>>>
>>>> Dear all,
>>>>
>>>> I found a strange thing with the snow package.
>>>>
>>>> This will work:
>>>> y = matrix(1:4, 2)
>>>> cl = makeCluster(rep('localhost', 8), type='SOCK')
>>>> parMM(cl, y, y)
>>>>
>>>> This will not:
>>>>
>>>> y = matrix(1:4, 2)
>>>> ncore = system('nproc')
>>>> parMM(cl, y, y)
>>>> Error in cut.default(i, breaks) : invalid number of intervals
>>>>
>>>> I also tried:
>>>> cl = makeCluster(rep('localhost', ncore), type='SOCK')
>>>> cl = makeCluster(rep('localhost', as.integer(ncore)), type='SOCK')
>>>>
>>>> no luck.
>>>>
>>>>
>>>> Could anyone please help? Thanks!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Best regards,
>>>>
>>>> Kaiyin ZHONG
>>>> ------------------------------
>>>> FMB, Erasmus MC
>>>> k.zhong at erasmusmc.nl
>>>> kindlychung at gmail.com
>>>>
>>>>      [[alternative HTML version deleted]]
>>>>
>>>> ______________________________**________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>>>> PLEASE do read the posting guide http://www.R-project.org/**
>>>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>>
>>
>> --
>> Jon Olav Skøien
>> Joint Research Centre - European Commission
>> Institute for Environment and Sustainability (IES)
>> Land Resource Management Unit
>>
>> Via Fermi 2749, TP 440,  I-21027 Ispra (VA), ITALY
>>
>> jon.skoien at jrc.ec.europa.eu
>> Tel:  +39 0332 789206
>>
>> Disclaimer: Views expressed in this email are those of the individual and
>> do not necessarily represent official views of the European Commission.
>>
>>
>>
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list