How can I get R to use more CPU usage?

前端 未结 2 1559
攒了一身酷
攒了一身酷 2021-01-19 01:27

I noticed that R doesn\'t use all of my CPU, and I want to increase that tremendously (upwards to 100%). I don\'t want it to just parallelize a few functions; I want R to us

2条回答
  •  终归单人心
    2021-01-19 01:57

    If you are trying to run 4 different LPs in parallel, here's how to do it in snowfall.

    sfInit(parallel=TRUE, cpus=4)
    sfSource(code.R) #if you have your function in a separate file
    sfExport(list=c("variable1","variable2",
                "functionname1")) #export your variables and function to cluster
    results<-sfClusterApplyLB(parameters, functionname) #this starts the function on the clusters
    

    E.g. The function in the sfClusterApply could contain your LP.

    Otherwise see comments in regard to your question

提交回复
热议问题