R parallel makeCluster() hangs infinitely on Mac

前端 未结 2 1860
梦毁少年i
梦毁少年i 2021-01-07 12:42

I came across some problem when I was trying to use parallel package in R on my Mac.

Here is how the parallel package works normally.

         


        
2条回答
  •  温柔的废话
    2021-01-07 13:27

    Several potential reasons includes not enough memory, installation error, etc. They do not seems to be the problem here, as I restarted sessions, reinstalled R, but the problem remained.

    Correct, those type of problems should not be involved here. The calls you've shown use basic built-in functionalities of R (mostly from the 'parallel' package) and there's very little memory usage involved.

    I guess the problem is about the permission when R tried to connect to cores. [...]

    Both parallel:makeCluster(2) and future::makeClusterPSOCK(2) launches workers (using the parallel:::.slaveRSOCK()) that are independent R sessions that run in the background. The master session and these workers communicate via sockets. So, yes, it could be that you have firewall issues preventing R from opening those ports. (I don't know enough macOS to troubleshoot that)

    By setting outfile = NULL, you will also get information on what happens on the workers' end. Here is what it should look like when it works:

    > cl <- future::makeClusterPSOCK(1, outfile = NULL, verbose = TRUE)
    Workers: [n = 1] ‘localhost’
    Base port: 11306
    Creating node 1 of 1 ...
    - setting up node
    Starting worker #1 on ‘localhost’: '/usr/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'parallel:::.slaveRSOCK()' MASTER=localhost PORT=11306 OUT= TIMEOUT=2592000 XDR=TRUE
    Waiting for worker #1 on ‘localhost’ to connect back
    starting worker pid=7608 on localhost:11306 at 14:46:57.827
    Connection with worker #1 on ‘localhost’ established
    - assigning connection UUID
    - collecting session information
    Creating node 1 of 1 ... done
    

    PS. You only need one worker to troubleshoot this.

提交回复
热议问题