[R] mclapply hanging occasionally on macos

Ivo Welch |vo@we|ch @end|ng |rom gm@||@com
Tue Dec 31 19:15:40 CET 2024


thank you, Ivan.  this is terrific.  your hunch was almost surely
correct.  the one that works (on the macbook air) is

```
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;
 LAPACK version 3.12.0
```

while the ones that fail (on the desktops) are

```
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin24.1.0
Running under: macOS Sequoia 15.2

Matrix products: default
BLAS:   /opt/homebrew/Cellar/openblas/0.3.28/lib/libopenblasp-r0.3.28.dylib
LAPACK: /opt/homebrew/Cellar/r/4.4.2_2/lib/R/lib/libRlapack.dylib;
LAPACK version 3.12.0
```

a presumably simple cure would presumably to deinstall the `brew`
version of R, and replace it with a direct install.








On Tue, Dec 31, 2024 at 6:11 AM Ivan Krylov <ikrylov using disroot.org> wrote:
>
> В Mon, 30 Dec 2024 19:16:11 -0800
> Ivo Welch <ivo.welch using gmail.com> пишет:
>
> > useless.function <- function( ) {
> >     y <- rnorm(3); x <- rnorm(3)
> >     summary( lm( y ~ x ))  ## useless
> >     NULL
> > }
> >
> > run30 <- function(i) {
> >     message("run30=", i)
> >     useless.function()
> > }
> >
> > run30( 0 )
> > message("many mc")
> > simsl <- mclapply( 1:30, run30 )
>
> Thank you for telling us which code you're running that eventually
> hangs mclapply()! I see that your example involves running lm(), which
> in turn involves BLAS and LAPACK operations. It could be that when you
> first run lm() in the parent process, it starts threads that take
> locks. Later, when mclapply() starts child processes, those threads
> don't exist there (they stay in the parent process), but the locks
> remain taken, with no-one to release them - a deadlock.
>
> Ironically, using a parallel "socket cluster" (but not "fork cluster")
> would have avoided the problem by starting a fresh process from
> scratch, without any inherited locks.
>
> It may also be possible to disable the use of parallel threads in your
> BLAS/LAPACK, but the exact procedure depends on the BLAS. What's your
> sessionInfo()? If you don't get a good answer here, try
> R-SIG-Mac using R-project.org.
>
> --
> Best regards,
> Ivan



More information about the R-help mailing list