[R-sig-hpc] Warning "closing unused connection..." with package parallel
Dirk Eddelbuettel
edd at debian.org
Mon Jan 23 03:14:38 CET 2012
On 22 January 2012 at 15:33, Zepu Zhang wrote:
| Dear list,
|
| After running the following chunk of code repeatedly in a package
|
| library(parellel)
|
| f <- function(nsim, ...)
| {
| cl <- makeCluster(detectCores())
| on.exit(stopCluster(cl))
| rng.kind <- RNGkind()
| on.exit(RNGkind(rng.kind[1], rng.kind[2]))
| RNGkind("L'Ecuyer-CMRG")
| clusterSetRNGStream(cl, trunc(runif(1) * 10000))
|
| z <- clusterApply(cl, seq_len(nsim),
| function(dummy, ...)
| { #some custom function that does simulation
| },
| # additional arguments passed into function
| )
| # other stuff
| }
|
| I got > 50 warnings like
|
| 34: closing unused connection 3 (<-localhost.localdomain:10187)
| 35: closing unused connection 4 (<-localhost.localdomain:10187)
| 36: closing unused connection 3 (<-localhost.localdomain:10187)
| 37: closing unused connection 4 (<-localhost.localdomain:10187)
| 38: closing unused connection 3 (<-localhost.localdomain:10187)
|
| I've tested this on two Linux boxes with detectCores() returning 2 and
| 4, respectively, getting the same type of warnings. Although 2 and 4
| cores seem to be few, I need this parallel capabilities so that it's
| beneficial when the code is run on machines with more cores. It will
| be run on both Linux and Windows.
|
| The function called by 'clusterApply' calls package 'RandomFields' for
| simulations. It is not apparent that 'RandomFields' does parallel
| computations (which might interfere with R).
|
| Any idea what caused these warning messages? If they are harmless, I
| really want to avoid them b/c they can mask other useful warnings.
Try calling stopCluster(cl) when you're done. The documentation, accessible
via help(makeCluster,package="parallel") states this:
It is good practice to shut down the workers by calling
‘stopCluster’: however the workers will terminate themselves once
the socket on which they are listening for commands becomes
unavailable, which it should if the master R session is completed
(or its process dies).
Dirk
|
| Thanks!
|
| Zepu Zhang
|
| _______________________________________________
| R-sig-hpc mailing list
| R-sig-hpc at r-project.org
| https://stat.ethz.ch/mailman/listinfo/r-sig-hpc
--
"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx
More information about the R-sig-hpc
mailing list