stan-dev / cmdstanr

CmdStanR: the R interface to CmdStan
https://mc-stan.org/cmdstanr/
Other
143 stars 63 forks source link

tbb.dll error #757

Open Ari04T opened 1 year ago

Ari04T commented 1 year ago

Describe the bug While attempting to run the cmdstanr_example() I get the following error:

error

To Reproduce

library(cmdstanr)

fit <- cmdstanr_example()

Expected behavior Run the model

Operating system Running R 4.2.1 in Windows 10.

> R.version
               _                                
platform       x86_64-w64-mingw32               
arch           x86_64                           
os             mingw32                          
crt            ucrt                             
system         x86_64, mingw32                  
status                                          
major          4                                
minor          2.1                              
year           2022                             
month          06                               
day            23                               
svn rev        82513                            
language       R                                
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname       Funny-Looking Kid 

CmdStanR version number

packageVersion("cmdstanr")
[1] ‘0.5.3’

Your CmdStanR version number (e.g. from packageVersion("cmdstanr")).

Additional context The output is in Spanish but it just says that it can't find the _ZN3tbb... procedure point of entrance in the library of dynamic links.

I've tried reinstalling rstan and its headers as well as their dependencies from source. The output of the cmdstan toolchain is successful and the path seems to be in a normal local library. I've also tried to rebuild cmdstan with rebuild_cmdstan() but to no avail. Rstan works just fine. Running example(stan_model, package = "rstan", run.dontrun = TRUE) compiles alright and it runs the resamples. Only when I try to use the cmdstan backend I get the error that I just showed.

> check_cmdstan_toolchain()
The C++ toolchain required for CmdStan is setup properly!
> cmdstan_path()
[1] "C:/Users/Sergio/Documents/.cmdstan/cmdstan-2.31.0"
Ari04T commented 1 year ago

Alright, so I discovered the problem. For some reason, the program is attempting to use tbb.dll from system32. I'm not even sure which program installed it there, but it's taking priority over the tbb.dll file that's in the cmdstan folder (and it has been included at the top of the path). Regardless of the path being set correctly, cmdstan still tries to use the tbb.dll file from system32. I'm not sure if this is caused by the Windows File Protection system but I'm guessing that's a possibility.

In any case, I changed the tbb.dll file name in system32 and the example model seems to run just fine. I'm not sure if there's a way to correct this directly in cmdstan or something but I'm leaving this comment here in case someone in the future gets the same problem. Maybe the title could be changed to tbb.dll error or similar? Thanks!