'makeCluster hangs on Windows - parallel package

I have tried using the parallel package to run a simple parallelization in R on my Windows 10 laptop, but when it gets to the makeCluster function it just hangs there. I tried running on the GUI, different number of cores, changing the settings on windows firewall and using the snow package, but to no avail.

This is the code I've been using:

library(doParallel) # basic parallelization package
ncore <- detectCores(logical = TRUE) # detect number of cores
cl <- makeCluster(ncore - 1, type = "PSOCK") # create clusters of ncore - 1

Does anyone that faced a similar problem know how to solve this? Thank you so much for the help!

Edit: As suggested, here is an excerpt of a log file for the running code. I tried looking into the error shown, but had no success:

=========================================================================
Log Path: ./log/script.log
Working Directory: 
User Name:
R Version: 4.1.2 (2021-11-01)
Machine: PC x86-64
Operating System: Windows >= 8 x64 build 9200
Log Start Time: 2021-11-14 16:28:41
=========================================================================

Testing makeCluster

NOTE: Log Print Time:  2021-11-14 16:28:41
NOTE: Elapsed Time in seconds: 0.00299715995788574

Error in makePSOCKcluster(names = spec, ...) : 
  Cluster setup failed. 3 of 3 workers failed to connect.


NOTE: Log Print Time:  2021-11-14 16:32:44
NOTE: Elapsed Time in seconds: 4.05511613289515

Error in print(x, ...) : object 'cl' not found


NOTE: Log Print Time:  2021-11-14 16:32:44
NOTE: Elapsed Time in seconds: 0.0109848976135254

=========================================================================
Log End Time: 2021-11-14 16:32:44
Log Elapsed Time: 0 00:00:04
=========================================================================


Solution 1:[1]

I was experiencing the same problem in R 4.0.4. makeCluster(ncore - 1, type = "SOCK") function was just hanging there (type="PSOCK" does not work on R 4.0.4). Try replacing the code with parallel::makePSOCKcluster(ncore - 1). I hope that works in your code, too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mehmet Yildirim