Cmdstan: mingw32-make.exe: *** [src/cmdstan/main_threads_opencl.o] Error 1

Hi everyone,

I want to run a brms model with opencl() function in Rstudio, windows 10 pro. See my code below:

library(brms)
# Compile and sample
fit <- brm(value ~ name,
           df,
           family = student(link_nu = "logm1"),
           iter = 2000,
           warmup = 1000,
           chains = 2,
           cores = 2,
           opencl = opencl(c(0, 0)),
           backend = "cmdstan")

But I got the following error messages:
###################################
At global scope:
cc1plus.exe: warning: unrecognized command line option “-Wno-ignored-attributes”
cc1plus.exe: warning: unrecognized command line option “-Wno-ignored-attributes”
cc1plus.exe: warning: unrecognized command line option “-Wno-int-in-bool-context”
mingw32-make.exe: *** [src/cmdstan/main_threads_opencl.o] Error 1
Error: An error occured during compilation! See the message above for more information.
###################################

I had tried some suggestions in other similar posts, like:

###########################################
cmdstan_make_local(cpp_options = “CXXFLAGS += -fpermissive”)
rebuild_cmdstan(cores = 4)
###########################################
or
###########################################
install_cmdstan(cores=4, overwrite = TRUE)
cmdstan_make_local(cpp_options = “CXXFLAGS += --Wno-int-in-bool-context”, append = TRUE)
path_to_opencl_lib ← “C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64”
cpp_options = list(
“CXXFLAGS += -fpermissive”,
“PRECOMPILED_HEADERS”=FALSE,
paste0(“LDFLAGS+= -L”",path_to_opencl_lib,"" -lOpenCL")
)
cmdstan_make_local(cpp_options = cpp_options)
rebuild_cmdstan(cores=4)
###########################################

But I still got the same error messages: “mingw32-make.exe: *** [src/cmdstan/main_threads_opencl.o] Error 1”.

And, everytime when I run the above code, it will show that “NOTE: Please add C:/Users/Administrator/Documents/.cmdstanr/cmdstan-2.27.0/stan/lib/stan_math/lib/tbb to your PATH variable. You may call mingw32-make install-tbb to automatically update your user configuration.”

I had added it into my path variable like this:

But it seems to be not helpful…I really need your help, thanks a lot!

Best,
Jacob

  • Operating System: win10
  • CmdStan Version: cmdstan 2.27.0
  • Compiler/Toolkit: g++

other versions of my packages:
R version 3.6.3
R studio Version 1.3.1056
brms 2.15.9
cmdstanr 0.4.0

Hi,

for OpenCL to work with Windows, you need to use Rtools 4.0, so you need to use R 4.x. The C++ compiler that comes with RTools 3.5 (g++ 4.9.3) does not support some of the features of the OpenCL backend. RTools 4.0 comes with g++ 8.3.0.

I would advise bumping to R4.X anyways for the new compiler, even if you are not using OpenCL. The compilation is much faster and the models tend to run faster as well.

Thanks a lot! I will upgrade my R to 4.0 version and try again!

Rok Češnovar via The Stan Forums <mc_stan@discoursemail.com>于2021年8月15日 周日下午5:31写道:

Thank you for your suggestions!
I had upgrade my R version to 4.1.1, and reinstall:
rtools 4.0
brms 2.15.9
cmdstanr 0.4.0.9000
cmdstan 2.27.0

but after I run the above code, I got another new error message:

Compiling Stan program...
In file included from stan/src/stan/model/model_header.hpp:18:
stan/src/stan/services/util/create_rng.hpp:35:1: internal compiler error: in gt_pch_note_object, at ggc-common.c:276
 }  // namespace stan
 ^

libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/r-windows> for instructions.

mingw32-make.exe: *** [make/program:25: stan/src/stan/model/model_header_opencl.hpp.gch] Error 1

Error: An error occured during compilation! See the message above for more information.

May I ask for more advice about this issue? Thanks a lot!

I don’t know the reason, but I sovle this issues by the following code:

remotes::install_github("stan-dev/cmdstanr")

path_to_opencl_lib <- "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.3/lib/x64"
cpp_options = list(
  "CXXFLAGS += -fpermissive",
  "PRECOMPILED_HEADERS"=FALSE,
  paste0("LDFLAGS+= -L\"",path_to_opencl_lib,"\" -lOpenCL")
)

install_cmdstan(cores=4, overwrite = TRUE, cpp_options = cpp_options)

Hope to help someone else!

Best,
Jacob

1 Like