traitecoevo / hmde

Implementation of hierarchical Bayesian longitudinal models to estimate differential equation parameters.
Other
2 stars 3 forks source link

Multiple cores failing to load #30

Closed Tess-LaCoil closed 3 months ago

Tess-LaCoil commented 3 months ago

Fresh updated version of R 4.4.1, I have installed rstan with dependencies, loading hmde from local github files. This occurs on both my ubuntu laptop and Windows PC, on master and function-update branches.

Problem is that if I use multiple cores I get an error:

#Succeeds
multi_ind_trout <- hmde_model("constant_multi_ind") |>
  hmde_assign_data(n_obs = nrow(Trout_Size_Data),         #integer
                   n_ind = length(unique(Trout_Size_Data$ind_id)),               #integer
                   y_obs = Trout_Size_Data$y_obs,         #vector length N_obs
                   obs_index = Trout_Size_Data$obs_index, #vector length N_obs
                   time = Trout_Size_Data$time,           #Vector length N_obs
                   ind_id = Trout_Size_Data$ind_id,       #Vector length N_obs
                   y_0_obs = Trout_Size_Data$y_obs[which(Trout_Size_Data$obs_index == 1)]           #vector length N_ind
  ) |>
  hmde_run(chains = 2, iter = 100, cores = 1,
           verbose = FALSE, show_messages = FALSE)

#Fails with following output:
#Succeeds
multi_ind_trout <- hmde_model("constant_multi_ind") |>
  hmde_assign_data(n_obs = nrow(Trout_Size_Data),         #integer
                   n_ind = length(unique(Trout_Size_Data$ind_id)),               #integer
                   y_obs = Trout_Size_Data$y_obs,         #vector length N_obs
                   obs_index = Trout_Size_Data$obs_index, #vector length N_obs
                   time = Trout_Size_Data$time,           #Vector length N_obs
                   ind_id = Trout_Size_Data$ind_id,       #Vector length N_obs
                   y_0_obs = Trout_Size_Data$y_obs[which(Trout_Size_Data$obs_index == 1)]           #vector length N_ind
  ) |>
  hmde_run(chains = 2, iter = 100, cores = 2,
           verbose = FALSE, show_messages = FALSE)

> starting worker pid=22647 on localhost:11851 at 13:47:56.510
> starting worker pid=22663 on localhost:11851 at 13:47:56.629
> Error in checkForRemoteErrors(val) :
> 2 nodes produced errors; first error: object 'rstantools_model_constant_multi_ind' not found

10.
stop(count, " nodes produced errors; first error: ", firstmsg,
domain = NA)
9.
checkForRemoteErrors(val)
8.
dynamicClusterApply(cl, fun, length(x), argfun)
7.
clusterApplyLB(cl = cl, x = splitList(X, nchunks), fun = lapply,
FUN = fun, ...)
6.
do.call(c, clusterApplyLB(cl = cl, x = splitList(X, nchunks),
fun = lapply, FUN = fun, ...), quote = TRUE)
5.
parallel::parLapplyLB(cl, X = 1:chains, fun = callFun)
4.
.local(object, ...)
3.
rstan::sampling(stanmodels$constant_multi_ind, data = model_template,
...)
2.
rstan::sampling(stanmodels$constant_multi_ind, data = model_template,
...) at hmde_run.R#12
1.
hmde_run(hmde_assign_data(hmde_model("constant_multi_ind"), n_obs = nrow(Trout_Size_Data),
n_ind = length(unique(Trout_Size_Data$ind_id)), y_obs = Trout_Size_Data$y_obs,
obs_index = Trout_Size_Data$obs_index, time = Trout_Size_Data$time,
ind_id = Trout_Size_Data$ind_id, y_0_obs = Trout_Size_Data$y_obs[which(Trout_Size_Data$obs_index == ...

My guess is that there's some dependency that's missing but I can't work out what it is. RcppParallel is installed.

dfalster commented 3 months ago

Just installed and the multicores option is working fine for me (on a Mac). so I can't reproduce and therefore troubleshoot.

Did you install the package, or just run load it with dev tools::load_all? If the latter, you might need to reinstall.

I would delete your previous installation, then reinstall.

to delete, run .libPaths(), to see where packages are installed. Go to that folder and delete hmde. and rmot. Then reisntall

Tess-LaCoil commented 3 months ago

This one got fixed by installing from remote rather than using local files.