title: Error in unserialize(socklist[[n]]) : error reading from connection on Unix
body: <p>I have tried running the following code on a Unix machine with 20 CPU, using R <code>foreach</code>, <code>parallel</code>, <code>doParallel</code>, and <code>party</code> packages (my objective is to have the party / varimp function working on several CPUs in parallel):</p>
  
  <pre><code>parallel_compute_varimp &lt;- function (object, mincriterion = 0, conditional = FALSE, threshold = 0.2, 
      nperm = 1, OOB = TRUE, pre1.0_0 = conditional) 
  {
      response &lt;- object@responses
      input &lt;- object@data@get("input")
      xnames &lt;- colnames(input)
      inp &lt;- initVariableFrame(input, trafo = NULL)
      y &lt;- object@responses@variables[[1]]
      error &lt;- function(x, oob) mean((levels(y)[sapply(x, which.max)] != y)[oob])
  
      w &lt;- object@initweights
      perror &lt;- matrix(0, nrow = nperm * length(object@ensemble), ncol = length(xnames))
      colnames(perror) &lt;- xnames
  
      data = foreach(b = 1:length(object@ensemble), .packages = c("party","stats"), .combine = rbind) %dopar%
      {
          try({
              tree &lt;- object@ensemble[[b]]
              oob &lt;- object@weights[[b]] == 0
  
              p &lt;- .Call("R_predict", tree, inp, mincriterion, -1L, PACKAGE = "party")
  
              eoob &lt;- error(p, oob)
  
              for (j in unique(varIDs(tree))) {
                  for (per in 1:nperm) {
                      if (conditional || pre1.0_0) {
                        tmp &lt;- inp
                        ccl &lt;- create_cond_list(conditional, threshold, xnames[j], input)
                        if (is.null(ccl)) {
                          perm &lt;- sample(which(oob))
                        }
                        else {
                          perm &lt;- conditional_perm(ccl, xnames, input, tree, oob)
                        }
                        tmp@variables[[j]][which(oob)] &lt;- tmp@variables[[j]][perm]
                        p &lt;- .Call("R_predict", tree, tmp, mincriterion, -1L, PACKAGE = "party")
                      }
                      else {
                        p &lt;- .Call("R_predict", tree, inp, mincriterion, as.integer(j), PACKAGE = "party")
                      }
                      perror[b, j] &lt;- (error(p, oob) - eoob)
                  }
              }
  
              ########
              # return data to the %dopar% loop data variable
              perror[b, ]
              ########
  
          }) # END OF TRY
      } # END OF LOOP WITH PARALLEL COMPUTING
  
      perror = data
      perror &lt;- as.data.frame(perror)
      return(MeanDecreaseAccuracy = colMeans(perror))
  }
  
  environment(parallel_compute_varimp) &lt;- asNamespace('party')
  
  
  cl &lt;- makeCluster(detectCores())
  registerDoParallel(cl, cores = detectCores())
  &lt;...&gt;
  system.time(data.cforest.varimp &lt;- parallel_compute_varimp(data.cforest, conditional = TRUE))
  </code></pre>
  
  <p>but I am getting an error:</p>
  
  <pre><code>&gt; system.time(data.cforest.varimp &lt;- parallel_compute_varimp(data.cforest, conditional = TRUE))
  Error in unserialize(socklist[[n]]) : error reading from connection
  Timing stopped at: 58.302 13.197 709.307
  </code></pre>
  
  <p>The code was working with a smaller dataset on 4 CPUs.</p>
  
  <p>I am running out of ideas. Can someone suggest a way to reach my objective of running party package varimp function on parallel CPUs?</p>