Error: Failed to create the shared library

202 views
Skip to first unread message

Xicheng Xie

unread,
Jul 31, 2023, 5:57:47 PM7/31/23
to nimble-users
Dear all,

I encountered the same problem when I was running a linear model on HPC cluster, and I got "Error: Failed to create the shared library". I have tried the 
foo <- nimbleFunction( run = function(x = double(1)) {return(sum(x)); returnType(double())})
cfoo <- compileNimble(foo)
cfoo(1:10)
which works good on the cluster, does that mean compiler setup is working, and so what's the problem of my code?
My code is like this:
#mcmc function
run_linear_mcmc<-function(data){
  # Model Definition
  model_code <- nimbleCode({
    beta0 ~ dnorm(0, sd = 100)
    beta1 ~ dnorm(0, sd = 100)
    sigma ~ dunif(0, 50)
    for(i in 1:N) {
      mean_wbgtmax[i] ~ dnorm(beta0 + beta1 * year[i], sd = sigma)
    }
  })
 
  # set the constant
  constants<-list(N=nrow(data))
  data_list <- list(mean_wbgtmax = data$mean_wbgtmax, year = data$year)
  inits <- list(beta0 = 0, beta1 = 0, sigma = 1)
  niter<- 10000
 
 
  # configure and run MCMC
  mcmc_output<-nimbleMCMC(code = model_code,
                          constants = constants,
                          data = data_list,
                          inits = inits,
                          monitors = c('beta0', 'beta1', 'sigma'),
                          niter = niter)
 
  # get the posterior summary
  beta1_samples <- mcmc_output[,"beta1"]
 
  mean_posterior <- mean(beta1_samples)
  ci <- quantile(beta1_samples, c(0.025, 0.975))
  prob_gt_0 <- mean(beta1_samples > 0)
 
 
  return(list(ct_id=unique(data$ct_id),mean = mean_posterior, ci = ci, prob_gt_0 = prob_gt_0))
}


Defining model
Building model
Setting data and initial values
Running calculate on model
  [Note] Any error reports that follow may simply reflect missing values in model variables.
Checking model sizes and dimensions
Checking model calculations
Compiling
  [Note] This may take a minute.
  [Note] Use 'showCompilerOutput = TRUE' to see C++ compilation details.
Error: Failed to create the shared library. Run 'printErrors()' to see the compilation errors.
Execution halted


Thank you so much for your help!!

Best ,
Xicheng

Chris Paciorek

unread,
Aug 9, 2023, 3:05:32 PM8/9/23
to Xicheng Xie, nimble-users
Hi Xicheng,

Sorry about the delay in anyone responding. Yes, your initial compilation check suggests the compiler is set up correctly.

I'm not sure why that simple model would result in a compilation error.

Please set this option first before running the code and let us know what error message you get.

nimbleOptions('showCompilerOutput' = TRUE)

--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/ca5d0a89-2051-4860-baee-16997e629cf6n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages