All models on Windows don't sample or sample at impossibly slow speed

Hi all,

I have been having a consistent issue trying to use pymc on Windows for several weeks. I had similar issues as in this thread, though I have been through multiple installations in the interim. Trying to run any NUTS sampling on even a simple model is impossible. If I don’t use

pytensor.config.cxx = ''"

Then the models will not sample and I will get an

"ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding" 

and the model won’t sample. If I do include this line, but try to sample from more than 1 core (for example, a simple logistic regression model from bambi like:

first_model = bmb.Model(
    "made ~ attempt_yards",
    pd_data,
    family='bernoulli'
)

first_model_idata = first_model.fit(
    draws=1000,
    random_seed = 0,
    chains = 4
)

ParallelSamplingError: Chain 0 failed with: The model could not be unpickled. This is required for sampling with more than one core and multiprocessing context spawn or forkserver.

[ ]:

If I instead specify to use a single core, the first chain estimates 3 hours of sampling time. I have listed my pymc_env packages below. I am really at my wits end and don’t know what to do.

# Name                    Version                   Build  Channel
_openmp_mutex             4.5                       2_gnu    conda-forge
_python_abi3_support      1.0                  hd8ed1ab_2    conda-forge
anyio                     4.9.0              pyh29332c3_0    conda-forge
argon2-cffi               23.1.0             pyhd8ed1ab_1    conda-forge
argon2-cffi-bindings      21.2.0          py313ha7868ed_5    conda-forge
arrow                     1.3.0              pyhd8ed1ab_1    conda-forge
arviz                     0.21.0             pyhd8ed1ab_0    conda-forge
asttokens                 3.0.0              pyhd8ed1ab_1    conda-forge
async-lru                 2.0.5              pyh29332c3_0    conda-forge
attrs                     25.3.0             pyh71513ae_0    conda-forge
babel                     2.17.0             pyhd8ed1ab_0    conda-forge
bambi                     0.13.0                   pypi_0    pypi
beautifulsoup4            4.13.4             pyha770c72_0    conda-forge
binutils_impl_win-64      2.43                 h095e170_4    conda-forge
binutils_win-64           2.43                 hd1c8def_4    conda-forge
blas                      2.131                       mkl    conda-forge
blas-devel                3.9.0           31_hfb1a452_mkl    conda-forge
bleach                    6.2.0              pyh29332c3_4    conda-forge
bleach-with-css           6.2.0                h82add2a_4    conda-forge
brotli                    1.1.0                h2466b09_2    conda-forge
brotli-bin                1.1.0                h2466b09_2    conda-forge
brotli-python             1.1.0           py313h5813708_2    conda-forge
bzip2                     1.0.8                h2466b09_7    conda-forge
ca-certificates           2025.4.26            h4c7d964_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cachetools                5.5.2              pyhd8ed1ab_0    conda-forge
cairo                     1.18.4               h5782bbf_0    conda-forge
certifi                   2025.4.26          pyhd8ed1ab_0    conda-forge
cffi                      1.17.1          py313ha7868ed_0    conda-forge
charset-normalizer        3.4.2              pyhd8ed1ab_0    conda-forge
cloudpickle               3.1.1              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_1    conda-forge
comm                      0.2.2              pyhd8ed1ab_1    conda-forge
cons                      0.4.6              pyhd8ed1ab_1    conda-forge
contourpy                 1.3.2           py313h1ec8472_0    conda-forge
cpython                   3.13.3          py313hd8ed1ab_101    conda-forge
cryptography              44.0.3                   pypi_0    pypi
cycler                    0.12.1             pyhd8ed1ab_1    conda-forge
debugpy                   1.8.14          py313h5813708_0    conda-forge
decorator                 5.2.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
deprecated                1.2.18                   pypi_0    pypi
etuples                   0.3.9              pyhd8ed1ab_1    conda-forge
exceptiongroup            1.2.2              pyhd8ed1ab_1    conda-forge
executing                 2.2.0              pyhd8ed1ab_0    conda-forge
filelock                  3.18.0             pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_3    conda-forge
fontconfig                2.15.0               h765892d_1    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.57.0          py313hb4c8b1a_0    conda-forge
formulae                  0.5.4                    pypi_0    pypi
fqdn                      1.5.1              pyhd8ed1ab_1    conda-forge
freetype                  2.13.3               h57928b3_1    conda-forge
fribidi                   1.0.10               h8d14728_0    conda-forge
gcc                       13.3.0               hf9c6911_2    conda-forge
gcc_impl_win-64           13.3.0               h14668b0_2    conda-forge
gcc_win-64                13.3.0              h3842d22_10    conda-forge
gendef                    v12.0.0.r1.ggdc42231f0      he1bec0e_1    conda-forge
getopt-win32              0.1                  hcfcfb64_1    conda-forge
graphite2                 1.3.13            h63175ca_1003    conda-forge
graphviz                  12.2.1               hf40819d_1    conda-forge
gts                       0.7.6                h6b5321d_4    conda-forge
gxx                       13.3.0               hf9c6911_2    conda-forge
gxx_impl_win-64           13.3.0               h317ec3d_2    conda-forge
gxx_win-64                13.3.0              h3842d22_10    conda-forge
h11                       0.16.0             pyhd8ed1ab_0    conda-forge
h2                        4.2.0              pyhd8ed1ab_0    conda-forge
h5netcdf                  1.6.1              pyhd8ed1ab_0    conda-forge
h5py                      3.13.0          nompi_py313h74a315e_101    conda-forge
harfbuzz                  11.1.0               h8796e6f_0    conda-forge
hdf5                      1.14.6          nompi_hd5d9e70_101    conda-forge
hpack                     4.1.0              pyhd8ed1ab_0    conda-forge
httpcore                  1.0.9              pyh29332c3_0    conda-forge
httpx                     0.28.1             pyhd8ed1ab_0    conda-forge
hyperframe                6.1.0              pyhd8ed1ab_0    conda-forge
icu                       75.1                 he0c23c2_0    conda-forge
idna                      3.10               pyhd8ed1ab_1    conda-forge
importlib-metadata        8.6.1              pyha770c72_0    conda-forge
importlib_resources       6.5.2              pyhd8ed1ab_0    conda-forge
intel-openmp              2024.2.1          h57928b3_1083    conda-forge
ipykernel                 6.29.5             pyh4bbf305_0    conda-forge
ipython                   9.2.0              pyhca29cf9_0    conda-forge
ipython_pygments_lexers   1.1.1              pyhd8ed1ab_0    conda-forge
ipywidgets                8.1.7              pyhd8ed1ab_0    conda-forge
isoduration               20.11.0            pyhd8ed1ab_1    conda-forge
jax                       0.6.0                    pypi_0    pypi
jaxlib                    0.6.0                    pypi_0    pypi
jedi                      0.19.2             pyhd8ed1ab_1    conda-forge
jinja2                    3.1.6              pyhd8ed1ab_0    conda-forge
json5                     0.12.0             pyhd8ed1ab_0    conda-forge
jsonpointer               3.0.0           py313hfa70ccb_1    conda-forge
jsonschema                4.23.0             pyhd8ed1ab_1    conda-forge
jsonschema-specifications 2025.4.1           pyh29332c3_0    conda-forge
jsonschema-with-format-nongpl 4.23.0               hd8ed1ab_1    conda-forge
jupyter                   1.1.1              pyhd8ed1ab_1    conda-forge
jupyter-lsp               2.2.5              pyhd8ed1ab_1    conda-forge
jupyter_client            8.6.3              pyhd8ed1ab_1    conda-forge
jupyter_console           6.6.3              pyhd8ed1ab_1    conda-forge
jupyter_core              5.7.2              pyh5737063_1    conda-forge
jupyter_events            0.12.0             pyh29332c3_0    conda-forge
jupyter_server            2.15.0             pyhd8ed1ab_0    conda-forge
jupyter_server_terminals  0.5.3              pyhd8ed1ab_1    conda-forge
jupyterlab                4.4.2              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.3.0              pyhd8ed1ab_2    conda-forge
jupyterlab_server         2.27.3             pyhd8ed1ab_1    conda-forge
jupyterlab_widgets        3.0.15             pyhd8ed1ab_0    conda-forge
kiwisolver                1.4.7           py313h1ec8472_0    conda-forge
krb5                      1.21.3               hdf4eb48_0    conda-forge
lcms2                     2.17                 hbcf6048_0    conda-forge
ld_impl_win-64            2.43                 hae1bf67_4    conda-forge
lerc                      4.0.0                h6470a55_1    conda-forge
libaec                    1.1.3                h63175ca_0    conda-forge
libblas                   3.9.0           31_h641d27c_mkl    conda-forge
libbrotlicommon           1.1.0                h2466b09_2    conda-forge
libbrotlidec              1.1.0                h2466b09_2    conda-forge
libbrotlienc              1.1.0                h2466b09_2    conda-forge
libcblas                  3.9.0           31_h5e41251_mkl    conda-forge
libcurl                   8.13.0               h88aaa65_0    conda-forge
libdeflate                1.23                 h76ddb4d_0    conda-forge
libexpat                  2.7.0                he0c23c2_0    conda-forge
libffi                    3.4.6                h537db12_1    conda-forge
libfreetype               2.13.3               h57928b3_1    conda-forge
libfreetype6              2.13.3               h0b5ce68_1    conda-forge
libgcc                    15.1.0               h1383e82_2    conda-forge
libgcc-devel_win-64       13.3.0             h5200ebd_102    conda-forge
libgd                     2.3.3               h7208af6_11    conda-forge
libglib                   2.84.1               hbc94333_1    conda-forge
libgomp                   15.1.0               h1383e82_2    conda-forge
libhwloc                  2.11.2          default_ha69328c_1001    conda-forge
libiconv                  1.18                 h135ad9c_1    conda-forge
libintl                   0.22.5               h5728263_3    conda-forge
libjpeg-turbo             3.1.0                h2466b09_0    conda-forge
liblapack                 3.9.0           31_h1aa476e_mkl    conda-forge
liblapacke                3.9.0           31_h845c4fa_mkl    conda-forge
liblzma                   5.8.1                h2466b09_1    conda-forge
libmpdec                  4.0.0                h2466b09_0    conda-forge
libpng                    1.6.47               h7a4582a_0    conda-forge
libsodium                 1.0.20               hc70643c_0    conda-forge
libsqlite                 3.49.2               h67fdade_0    conda-forge
libssh2                   1.11.1               h9aa295b_0    conda-forge
libstdcxx                 15.1.0               h904f734_2    conda-forge
libstdcxx-devel_win-64    13.3.0             h5200ebd_102    conda-forge
libtiff                   4.7.0                h797046b_4    conda-forge
libwebp-base              1.5.0                h3b0e114_0    conda-forge
libwinpthread             12.0.0.r4.gg4f2fc60ca      h57928b3_9    conda-forge
libxcb                    1.17.0               h0e4246c_0    conda-forge
libxml2                   2.13.8               h442d1da_0    conda-forge
libzlib                   1.3.1                h2466b09_2    conda-forge
lightgbm                  4.6.0                    pypi_0    pypi
llvmlite                  0.44.0          py313hb80970b_1    conda-forge
logical-unification       0.4.6              pyhd8ed1ab_0    conda-forge
lxml                      5.4.0                    pypi_0    pypi
m2w64-sysroot_win-64      12.0.0.r4.gg4f2fc60ca      h7428d3b_9    conda-forge
markdown-it-py            3.0.0              pyhd8ed1ab_1    conda-forge
markupsafe                3.0.2           py313hb4c8b1a_1    conda-forge
matplotlib-base           3.10.3          py313h81b4f16_0    conda-forge
matplotlib-inline         0.1.7              pyhd8ed1ab_1    conda-forge
mdurl                     0.1.2              pyhd8ed1ab_1    conda-forge
miceforest                6.0.3                    pypi_0    pypi
mingw-w64-ucrt-x86_64-crt-git 12.0.0.r4.gg4f2fc60ca      h7428d3b_9    conda-forge
mingw-w64-ucrt-x86_64-headers-git 12.0.0.r4.gg4f2fc60ca      h7428d3b_9    conda-forge
mingw-w64-ucrt-x86_64-windows-default-manifest 6.4                  he206cdd_7    conda-forge
mingw-w64-ucrt-x86_64-winpthreads-git 12.0.0.r4.gg4f2fc60ca      h7428d3b_9    conda-forge
minikanren                1.0.3              pyhd8ed1ab_1    conda-forge
mistune                   3.1.3              pyh29332c3_0    conda-forge
mkl                       2024.2.2            h66d3029_15    conda-forge
mkl-devel                 2024.2.2            h57928b3_15    conda-forge
mkl-include               2024.2.2            h66d3029_15    conda-forge
mkl-service               2.4.2           py313hb149f7d_1    conda-forge
ml-dtypes                 0.5.1                    pypi_0    pypi
multipledispatch          0.6.0              pyhd8ed1ab_1    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
nbclient                  0.10.2             pyhd8ed1ab_0    conda-forge
nbconvert-core            7.16.6             pyh29332c3_0    conda-forge
nbformat                  5.10.4             pyhd8ed1ab_1    conda-forge
nest-asyncio              1.6.0              pyhd8ed1ab_1    conda-forge
notebook                  7.4.2              pyhd8ed1ab_0    conda-forge
notebook-shim             0.2.4              pyhd8ed1ab_1    conda-forge
numba                     0.61.2          py313h4ca4f0f_0    conda-forge
numpy                     2.2.5           py313hefb8edb_0    conda-forge
numpyro                   0.18.0                   pypi_0    pypi
nutpie                    0.14.3                   pypi_0    pypi
openjpeg                  2.5.3                h4d64b90_0    conda-forge
openssl                   3.5.0                ha4e3fda_1    conda-forge
opt-einsum                3.4.0                    pypi_0    pypi
overrides                 7.7.0              pyhd8ed1ab_1    conda-forge
packaging                 25.0               pyh29332c3_1    conda-forge
pandas                    2.2.3           py313hf91d08e_3    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
pango                     1.56.3               h0c53d3b_1    conda-forge
parso                     0.8.4              pyhd8ed1ab_1    conda-forge
patsy                     1.0.1                    pypi_0    pypi
pcre2                     10.45                h99c9b8b_0    conda-forge
pickleshare               0.7.5           pyhd8ed1ab_1004    conda-forge
pillow                    11.2.1          py313hda88b71_0    conda-forge
pip                       25.1.1             pyh145f28c_0    conda-forge
pixman                    0.46.0               had0cd8c_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_2    conda-forge
platformdirs              4.3.8              pyhe01879c_0    conda-forge
polars                    1.29.0           py39haf3f19b_0    conda-forge
prometheus_client         0.21.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.51             pyha770c72_0    conda-forge
prompt_toolkit            3.0.51               hd8ed1ab_0    conda-forge
psutil                    7.0.0           py313ha7868ed_0    conda-forge
pthread-stubs             0.4               h0e40799_1002    conda-forge
pure_eval                 0.2.3              pyhd8ed1ab_1    conda-forge
pyarrow                   20.0.0                   pypi_0    pypi
pybaseball                2.2.7                    pypi_0    pypi
pycparser                 2.22               pyh29332c3_1    conda-forge
pygithub                  2.6.1                    pypi_0    pypi
pygments                  2.19.1             pyhd8ed1ab_0    conda-forge
pyjwt                     2.10.1                   pypi_0    pypi
pymc                      5.22.0               hd8ed1ab_0    conda-forge
pymc-base                 5.22.0             pyhd8ed1ab_0    conda-forge
pynacl                    1.5.0                    pypi_0    pypi
pyparsing                 3.2.3              pyhd8ed1ab_1    conda-forge
pysocks                   1.7.1              pyh09c184e_7    conda-forge
pytensor                  2.30.3          py313h62d098f_0    conda-forge
pytensor-base             2.30.3          np2py313h3710a23_0    conda-forge
python                    3.13.3          h261c0b1_101_cp313    conda-forge
python-dateutil           2.9.0.post0        pyhff2d567_1    conda-forge
python-fastjsonschema     2.21.1             pyhd8ed1ab_0    conda-forge
python-gil                3.13.3             h4df99d1_101    conda-forge
python-graphviz           0.20.3             pyh91182bf_2    conda-forge
python-json-logger        2.0.7              pyhd8ed1ab_0    conda-forge
python-tzdata             2025.2             pyhd8ed1ab_0    conda-forge
python_abi                3.13                    7_cp313    conda-forge
pytz                      2025.2             pyhd8ed1ab_0    conda-forge
pywin32                   307             py313h5813708_3    conda-forge
pywinpty                  2.0.15          py313h5813708_0    conda-forge
pyyaml                    6.0.2           py313hb4c8b1a_2    conda-forge
pyzmq                     26.4.0          py313h2100fd5_0    conda-forge
qhull                     2020.2               hc790b64_5    conda-forge
referencing               0.36.2             pyh29332c3_0    conda-forge
requests                  2.32.3             pyhd8ed1ab_1    conda-forge
rfc3339-validator         0.1.4              pyhd8ed1ab_1    conda-forge
rfc3986-validator         0.1.1              pyh9f0ad1d_0    conda-forge
rich                      14.0.0             pyh29332c3_0    conda-forge
rpds-py                   0.24.0          py313h54fc02f_0    conda-forge
scipy                     1.15.2          py313h2eca4b9_0    conda-forge
seaborn                   0.13.2                   pypi_0    pypi
send2trash                1.8.3              pyh5737063_1    conda-forge
setuptools                80.1.0             pyhff2d567_0    conda-forge
six                       1.17.0             pyhd8ed1ab_0    conda-forge
sniffio                   1.3.1              pyhd8ed1ab_1    conda-forge
soupsieve                 2.7                pyhd8ed1ab_0    conda-forge
stack_data                0.6.3              pyhd8ed1ab_1    conda-forge
statsmodels               0.14.4                   pypi_0    pypi
tbb                       2021.13.0            h62715c5_1    conda-forge
terminado                 0.18.1             pyh5737063_0    conda-forge
threadpoolctl             3.6.0              pyhecae5ae_0    conda-forge
tinycss2                  1.4.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h5226925_1    conda-forge
tomli                     2.2.1              pyhd8ed1ab_1    conda-forge
toolz                     1.0.0              pyhd8ed1ab_1    conda-forge
tornado                   6.4.2           py313ha7868ed_0    conda-forge
tqdm                      4.67.1                   pypi_0    pypi
traitlets                 5.14.3             pyhd8ed1ab_1    conda-forge
types-python-dateutil     2.9.0.20241206     pyhd8ed1ab_0    conda-forge
typing-extensions         4.13.2               h0e9735f_0    conda-forge
typing_extensions         4.13.2             pyh29332c3_0    conda-forge
typing_utils              0.1.0              pyhd8ed1ab_1    conda-forge
tzdata                    2025b                h78e105d_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_1    conda-forge
uri-template              1.3.0              pyhd8ed1ab_1    conda-forge
urllib3                   2.4.0              pyhd8ed1ab_0    conda-forge
vc                        14.3                h2b53caa_26    conda-forge
vc14_runtime              14.42.34438         hfd919c2_26    conda-forge
vs2015_runtime            14.42.34438         h7142326_26    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_1    conda-forge
webcolors                 24.11.1            pyhd8ed1ab_0    conda-forge
webencodings              0.5.1              pyhd8ed1ab_3    conda-forge
websocket-client          1.8.0              pyhd8ed1ab_1    conda-forge
widgetsnbextension        4.0.14             pyhd8ed1ab_0    conda-forge
win_inet_pton             1.1.0              pyh7428d3b_8    conda-forge
winpty                    0.4.3                         4    conda-forge
wrapt                     1.17.2                   pypi_0    pypi
xarray                    2025.4.0           pyhd8ed1ab_0    conda-forge
xarray-einstats           0.8.0              pyhd8ed1ab_1    conda-forge
xorg-libice               1.1.2                h0e40799_0    conda-forge
xorg-libsm                1.2.6                h0e40799_0    conda-forge
xorg-libx11               1.8.12               hf48077a_0    conda-forge
xorg-libxau               1.0.12               h0e40799_0    conda-forge
xorg-libxdmcp             1.1.5                h0e40799_0    conda-forge
xorg-libxext              1.3.6                h0e40799_0    conda-forge
xorg-libxpm               3.5.17               h0e40799_1    conda-forge
xorg-libxt                1.3.1                h0e40799_0    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
zeromq                    4.3.5                ha9f60a1_7    conda-forge
zipp                      3.21.0             pyhd8ed1ab_1    conda-forge
zstandard                 0.23.0          py313ha7868ed_2    conda-forge
zstd                      1.5.7                hbeecb71_2    conda-forge

You can install numba and use compile_kwargs={"mode": "NUMBA"} in pm.sample.

If that still fails with multiple chains, install nutpie and pass nuts_sampler="nutpie" to pm.sample

If you’re using bambi, check their documentation on how to use nutpie for sampling