Future_sapply from future.apply R package does not work on Linux - Stack Overflow

admin2025-04-21  2

I am trying to use parallelism for my code, when I execute it on Windows everything runs fine, but I need to use a Linux cluster and there all the values are just NaN, I executed every individual part of the code and found that the problem is here

bet_integ2 <- function(j, k) {
i <- seq(1, N1)
MC11 <- try({
mean(future.apply::future_sapply(i, integ11, Theta11 = Theta11, Theta22 = Theta22, N1 = N1, k = k, j = j))
})
if (!is.numeric(MC11)) return(NA_real_)
return(MC11)
}

m_grid_k <- round(seq(0.9091, 1.0000, length.out = 10), 4)
j <- seq(1, N2)



globals <- c("j", "bet_integ2", "m_grid_k", "N1")

furrr_options <- furrr_options(
 globals = globals, 
 seed = TRUE,       
 stdout = TRUE       
)

beta_result_integral100 <- future_map_dbl(
m_grid_k,
~ mean(future.apply::future_sapply(j, bet_integ2, k = .x), na.rm = TRUE),
.options = furrr_options
)

I am not really sure what should I change to be able to run it on the Linux cluster, this is the multisession plan

Sys.setenv("R_MAX_NUM_DLL" = 9999999)

mtime <- Sys.time()  
seed <- 123
n_bootstrap <- 500  

library(dplyr)
library(purrr)
library(hypergeo)
library(ggplot2)
library(parallel)
library(gtools)
library(GA)
library(future)
library(rstan)
library(furrr)
library(MCMCpack)
library(future.apply)

cores <- parallel::detectCores(logical = TRUE)  
plan(multisession, workers = cores)   

I am not sure if anyone can help with this

转载请注明原文地址:http://anycun.com/QandA/1745225250a90452.html