Bioconductor / BiocParallel

Bioconductor facilities for parallel evaluation
https://bioconductor.org/packages/BiocParallel
65 stars 29 forks source link

Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal #237

Closed nickhsmith closed 1 year ago

nickhsmith commented 1 year ago

Like the title suggests I'm getting the following error when trying to use BiocParallel (bplapply) using my tool OUTRIDER.

It seems as I'm not the only one as the variancePartition package is also having errors in parallel

When I try to run my command

register(MulticoreParam(8))
OUTRIDER(ods) # command using bplapply

I get this error Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal

If instead of MulticoreParam, I use SnowParam(8). I get this error: Error in serialize(data, node$con) : error writing to connection

This seems to be fixed by dropping the BiocParallel version down to BiocParallel_1.10.1 The problem seems to go away.

Thanks in advance, and I hope this can be fixed easily

mtmorgan commented 1 year ago

Can you provide a more completely reproducible example?

nickhsmith commented 1 year ago

I'm working on finding an example with data I can share. Sorry for the vagueness.

nickhsmith commented 1 year ago

Sorry for the delay, this is a more reproducible set of instructions. On a linux server

in the conda environment generated by the following

mamba create -n outrider -c bioconda bioconductor-outrider

in R 4.2.2

library(OUTRIDER)
ods <- readRDS("test_ods.RDS")
register(MulticoreParam(20))
OUTRIDER(ods)

gives the following output

> OUTRIDER(ods)
Fri Dec 16 19:41:10 2022: SizeFactor estimation ...
Fri Dec 16 19:41:11 2022: Controlling for confounders ...
Using provided q with: 44
Fri Dec 16 19:41:11 2022: Using the autoencoder implementation for controlling.
[1] "Fri Dec 16 19:41:17 2022: Initial PCA loss: 6.7195743956208"

    Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Error in serialize(data, node$con, xdr = FALSE) : 
  error writing to connection

bpparam() gives the following

class: MulticoreParam
bpisup: FALSE; bpnworkers: 20; bptasks: 0; bpjobname: BPJOB
bplog: FALSE; bpthreshold: INFO; bpstopOnError: TRUE
bpRNGseed: ; bptimeout: NA; bpprogressbar: FALSE
bpexportglobals: TRUE; bpexportvariables: FALSE; bpforceGC: TRUE; bpfallback: TRUE
bplogdir: NA
bpresultdir: NA
cluster type: FORK

It fails if I register anything more than a single worker. However if I downgrade the biocparallel version it does work with a MulticoreParam(20)

Attached is a tar file containing the RDS object (containing publically available data) and the yaml description github_upload.tar.gz

mtmorgan commented 1 year ago

Sorry for the delay. I think the basic problem is that the workers drop their connection if they've been idle for more than options("timeout") seconds, which is by default 60 seconds. This can be emulated with

library(BiocParallel)
options(timeout = 10)
register(MulticoreParam(2))
bpstart()
Sys.sleep(11)  # oh oh, workers have closed their connections...
res <- bplapply(1:10, identity)

resulting in

Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Error in serialize(data, node$con, xdr = FALSE) : 
  error writing to connection

A workaround is to set options(timeout = 60 * 60) for instance. I thought that MulticoreParam(timeout = 60*60) would help, but that sets the maximum computation time. I believe the Bioconductor build systems process the OUTRIDER vignette (which has a realistic dataset) because it sets the environment variable R_DEFAULT_INTERNET_TIMEOUT=600

We'll try to arrive at a more permanent solution or at least a more informative error message @Jiefei-Wang .

mtmorgan commented 1 year ago

This should be fixed in BiocParallel 1.33.8 (devel) or 1.32.5 (release), which should propagate in the next 48 hours.