@@ -949,21 +949,33 @@ def sample(
949949 if (
950950 force_one_process_per_chain is None
951951 and not cmdstan_version_before (2 , 28 , info_dict )
952+ and stan_threads is not None
952953 and stan_threads == 'true'
953954 ):
954955 one_process_per_chain = False
955956 num_threads = parallel_chains * num_threads
956957 parallel_procs = 1
957- elif (
958- force_one_process_per_chain is False
959- and cmdstan_version_before (2 , 28 , info_dict )
960- ):
961- get_logger ().warning (
962- 'Installed version of CmdStan cannot multi-process chains, '
963- 'will run %d processes. '
964- 'Run "install_cmdstan" to upgrade to latest version.' ,
965- chains ,
966- )
958+ if force_one_process_per_chain is False :
959+ if cmdstan_version_before (2 , 28 , info_dict ):
960+ get_logger ().warning (
961+ 'Installed version of CmdStan cannot multi-process '
962+ 'chains, will run %d processes. '
963+ 'Run "install_cmdstan" to upgrade to latest version.' ,
964+ chains ,
965+ )
966+ elif stan_threads is None or stan_threads == 'false' :
967+ get_logger ().warning (
968+ 'Stan program not compiled for threading, '
969+ 'will run %d processes. '
970+ 'Recompile model and specify argument '
971+ '"cpp_options={\' STAN_THREADS\' :\' TRUE\' }.' ,
972+ chains ,
973+ )
974+ else :
975+ one_process_per_chain = False
976+ num_threads = parallel_chains * num_threads
977+ parallel_procs = 1
978+
967979 os .environ ['STAN_NUM_THREADS' ] = str (num_threads )
968980
969981 if show_console :
0 commit comments