WARNING (aesara.tensor.blas): Using NumPy C-API based implementation for BLAS functions

I’m having issues when importing pymc… I get the error WARNING (aesara.tensor.blas): Using NumPy C-API based implementation for BLAS functions..

Following this discussion I removed my conda environment and will start fresh from a new one… and will install using mamba instead of conda to install pymc.

I was wondering if its OK to have Python on version 3.11 or should I just keep the new env with Python 3.9?

—EDIT----

I have followed those steps and I still get the warning mentioned above when importing pymc. Any ideas how to fix this?

Thank you!

Hi, are you by chance using a Jupyter Notebook within VScode? I get the same issue in VScode but if I actually launch Jupyter in the web browser that warning disappears for me.

2 Likes

No… that is using Jupyter in the browser…

Hey! Actually that’s not an error, just a warning – PyMC is telling you that it’s gonna use the Numpy C backend, which may be slower for some advanced operations.
So, if your use-case is not too complex, you don’t need to worry about.

Overall, that thing depends on a lot of variables-- which platform you’re using, which version of PyMC, etc.

Hope that helps, and PyMCheers :vulcan_salute:

Hi!
Thanks for your reply.

I understand its just a Warning but I would definitely prefer the speed of C instead of the speed of Python :p.

That warning happens when I run it in my work laptop which is Windows. On my personal laptop it works fine.

I have had issues with PyMC in that laptop before and I had to install conda to install the w64-toolchains. This solved some issues, but I still get that Warning…

Any idea how I could go about to fix or troubleshoot this? As mentioned before, the tips of installing pymc with mamba didn’t change anything.

Thanks!

I saw the same error when using vscode.

import pymc as pm
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

print(pm__version__)
5.0.0

with pm.Model() as basic_model:

    # Priors for unknown model parameters
    alpha = pm.Normal("alpha", mu=0, sigma=10)
    beta = pm.Normal("beta", mu=0, sigma=10, shape=2)

ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding
ERROR (pytensor.graph.rewriting.basic): node: InplaceDimShuffle{}(TensorConstant{(1,) of 2})
ERROR (pytensor.graph.rewriting.basic): TRACEBACK:
ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last):
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py", line 1933, in process_node
    replacements = node_rewriter.transform(fgraph, node)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/graph/rewriting/basic.py", line 1092, in transform
    return self.fn(fgraph, node)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/tensor/rewriting/basic.py", line 1141, in constant_folding
    thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/op.py", line 131, in make_thunk
    return self.make_c_thunk(node, storage_map, compute_map, no_recycling)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/op.py", line 96, in make_c_thunk
    outputs = cl.make_thunk(
              ^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1202, in make_thunk
    cthunk, module, in_storage, out_storage, error_storage = self.__compile__(
                                                             ^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1122, in __compile__
    thunk, module = self.cthunk_factory(
                    ^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1647, in cthunk_factory
    module = cache.module_from_key(key=key, lnk=self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 1229, in module_from_key
    module = lnk.compile_cmodule(location)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/basic.py", line 1546, in compile_cmodule
    module = c_compiler.compile_str(
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/cmodule.py", line 2641, in compile_str
    raise CompileError(
pytensor.link.c.exceptions.CompileError: Compilation failed (return status=1):
/Users/ruyuan/opt/miniconda3/envs/pymc_env/bin/clang++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/numpy/core/include -I/Users/ruyuan/opt/miniconda3/envs/pymc_env/include/python3.11 -I/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib/python3.11/site-packages/pytensor/link/c/c_code -L/Users/ruyuan/opt/miniconda3/envs/pymc_env/lib -fvisibility=hidden -o /Users/ruyuan/.pytensor/compiledir_macOS-11.7-x86_64-i386-64bit-i386-3.11.0-64/tmpoh2u6l_j/mdb3a1a186c6e0c789bc6494774a591ac6d8ab11d3ed19bf02a4ff96ab64fa9ba.so /Users/ruyuan/.pytensor/compiledir_macOS-11.7-x86_64-i386-64bit-i386-3.11.0-64/tmpoh2u6l_j/mod.cpp
In file included from /Users/ruyuan/.pytensor/compiledir_macOS-11.7-x86_64-i386-64bit-i386-3.11.0-64/tmpoh2u6l_j/mod.cpp:1:
In file included from /Users/ruyuan/opt/miniconda3/envs/pymc_env/include/python3.11/Python.h:23:
/Users/ruyuan/opt/miniconda3/envs/pymc_env/bin/../include/c++/v1/stdlib.h:93:15: fatal error: 'stdlib.h' file not found
#include_next <stdlib.h>
              ^~~~~~~~~~
1 error generated.

Basically, I cannot use pymc in vscode. But opening a jupyter notebook in a browser is OK.

PyMC is not yet being testing on python 3.11. Is that what you finally went with?

@ruyuanzhang I was getting this warning on my jupyter notebook and that had to do with the version of Python I was using in the notebook. It was fixed once I created a new kernel on my virtual env and set the Python version to 3.8 (or maybe 3.9).

Maybe your jupyter notebook runs on 3.8~3.9 and your VSCode on 3.11 and that’s why you get errors on VSCode and not jupyter notebook?

@guin0x @cluhmann Thanks so much. I checked both jupyter notebook in browsers and vscode. It shows both 3.11. Maybe 3.11 is too new. But the default installation of pymc requires 3.11. Better to force it to 3.10??

I can run everything fine on M1 and 3.11.

1 Like

Same