R - problem with foreach %dopar% inside function called by optim

后端 未结 3 2030
孤城傲影
孤城傲影 2020-12-28 17:22

Calling a function that includes foreach %dopar% construct from optim causes an error:

> workers <- startWorkers(6) # 6 cores
> 
> registerDoSMP(         


        
3条回答
  •  失恋的感觉
    2020-12-28 17:58

    Quick fix for problem with foreach %dopar% is to reinstall these packages:

    install.packages("doSNOW")
    
    install.packages("doParallel") 
    
    install.packages("doMPI")
    

    As mentioned in various threads at StackOverflow, these are responsible for parallelism in R. Bug which existed in old versions of these packages is now removed. It worked in my case. I should mention that it will most likely help even though you are not using these packages in your project/package.

提交回复
热议问题