Hi there. I’m getting a partial specialization error during model compilation when opencl is turned on. The error I get is shown below. I’m trying to run the example found here after following their installation instructions. I also tried editing cmdstan-2.26.1/make/local as per these instructions, but ended up getting a similar error when I tried python3 ./runCmdStanTests.py test/unit -f opencl
. The model runs normally when I don’t use opencl. My GPU (RTX 3070) is pretty new if it’s possible that that could be related?
Operating System: Linux Mint 20.1
Interface Version: cmdstanr 0.3.0.9000 + cmdstan 2.26.1
Compiler/Toolkit: g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 and GNU Make 4.2.1
For reference, the opencl logistic regression example code is this:
library(cmdstanr)
data_path <- "./lr_glm.data.json"
model_path <- "./lr_glm.stan"
opencl_options = list(
stan_opencl = TRUE,
opencl_platform_id = 0, # replace the ID based on step 3
opencl_device_id = 0 # replace the ID based on step 3
)
mod <- cmdstan_model(model_path, cpp_options = opencl_options, quiet = FALSE) # Fails here
fit <- mod$sample(data = data_path, num_samples=500, num_warmup = 500, num_chains = 1, num_cores = 1)
print(fit$summary())
This is the error message that shows up when the model tries to compile:
Compiling Stan program...
--- Compiling the main object file. This might take up to a minute. ---
g++ -std=c++1y -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -I stan/lib/stan_math/lib/opencl_2.2.0 -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.6.1/include -DBOOST_DISABLE_ASSERTS -DSTAN_OPENCL -DOPENCL_DEVICE_ID=0 -DOPENCL_PLATFORM_ID=0 -DCL_HPP_TARGET_OPENCL_VERSION=120 -DCL_HPP_MINIMUM_OPENCL_VERSION=120 -DCL_HPP_ENABLE_EXCEPTIONS -Wno-ignored-attributes -c -o src/cmdstan/main_opencl.o src/cmdstan/main.cpp
In file included from stan/lib/stan_math/stan/math/opencl/prim.hpp:86,
from stan/lib/stan_math/stan/math/prim.hpp:7,
from stan/src/stan/io/dump.hpp:7,
from src/cmdstan/command.hpp:24,
from src/cmdstan/main.cpp:1:
stan/lib/stan_math/stan/math/opencl/scalar_type.hpp:14:8: error: partial specialization of ‘struct stan::scalar_type<T, typename std::enable_if<stan::math::conjunction<stan::is_kernel_expression_and_not_scalar<T, void> >::value, void>::type>’ after instantiation of ‘struct stan::scalar_type<stan::math::constant_<int>, void>’ [-fpermissive]
14 | struct scalar_type<T, require_all_kernel_expressions_and_none_scalar_t<T>> {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from stan/lib/stan_math/stan/math/opencl/prim.hpp:86,
from stan/lib/stan_math/stan/math/prim.hpp:7,
from stan/src/stan/io/dump.hpp:7,
from src/cmdstan/command.hpp:24,
from src/cmdstan/main.cpp:1:
stan/lib/stan_math/stan/math/opencl/scalar_type.hpp:14:8: error: partial specialization of ‘struct stan::scalar_type<T, typename std::enable_if<stan::math::conjunction<stan::is_kernel_expression_and_not_scalar<T, void> >::value, void>::type>’ after instantiation of ‘struct stan::scalar_type<stan::math::constant_<int>, void>’ [-fpermissive]
14 | struct scalar_type<T, require_all_kernel_expressions_and_none_scalar_t<T>> {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [make/program:14: src/cmdstan/main_opencl.o] Error 1
make: *** [make/program:14: src/cmdstan/main_opencl.o] Error 1
Error: An error occured during compilation! See the message above for more information.