WARNING (pytensor.tensor.blas)

Short summary:
It appears when PyMC is installed by itself it installs PyTensor but for some reason does not install gcc and g++, so it defaults to the system compiler. When PyTensor is installed by itself gcc and g++ are installed in the mamba environment as expected. From @cluhmann 's comments it looks like it’s known that some conda installations can pull from the wrong channel and result in not installing the C tool chain, but I think I demonstrate that I’m pulling only from conda-forge.

Should I try the Numba workaround? And if so do I use the Conda version or Pip version of PyMC?

pytensor.config.mode=”NUMBA” 
pytensor.config.cxx=""

Also if NUMBA works would models previously generated with default settings be reproducible?

Full post:
I’m having a similar issue with code that previously worked and I really need to be able to reproduce, ideally with the same compiler. I probably messed myself up by installing a new package in my mamba environment, although I also installed an updated system g++ which for whatever reason seems to keep being found as the default compiler, even though it appears g++ is independently installed in the separated mamba environment. As far as I can tell there may be an issue with the conda/mamba package for PyMC or PyTensor so it doesn’t choose the correct g++. Even manually changing the pytensor.config.cxx variable to the /bin/g++ did not seem to fix the issue.

I’ll try to create a minimal reproduction to guarantee that my analysis environment isn’t responsible.

  1. System g++, no mamba environment
> which g++
/usr/local/bin/g++

g++ --version
g++ (GCC) 15.0.0 20240718 (experimental)
  1. Mimimal pymc environment, adapted from @maresb 's suggestion to use Mamba and a path prefix.
mamba create --prefix pymc-env -c conda-forge -c nodefaults ipykernel "pymc>=5"

Selected package versions

Blockquote
pymc 5.16.2 hd8ed1ab_0 conda-forge
pymc-base 5.16.2 pyhd8ed1ab_0 conda-forge
pytensor 2.23.0 py312h526ad5a_0
pytensor-base 2.25.3 py312h25a0e75_0 conda-forge
python 3.12.5 h2ad013b_0_cpython conda-forge

Tried to pick out the compilers installed by mamba

Blockquote
_libgcc_mutex 0.1 conda_forge conda-forge
libgcc-ng 14.1.0 h77fa898_0 conda-forge

Verified that system g++ was found in the mamba environment

(pymc-env) >>> which g++
/usr/local/bin/g++

Opened Python prompt and also verified PyTensor was also finding system g++

>>> print(pytensor.config.cxx)
/usr/local/bin/g++

I wanted to see what would happen with a minimal installation of the same version of PyTensor

mamba create --prefix pytensor-env -c conda-forge -c nodefaults ipykernel "pytensor=2.23.0"

Blockquote
pytensor 2.23.0 py312h7070661_0 conda-forge
pytensor-base 2.23.0 py312h266a736_0 conda-forge

It apparently installs gcc and g++

Blockquote
_libgcc_mutex 0.1 conda_forge conda-forge
gcc 12.4.0 h236703b_0 conda-forge
gcc_impl_linux-64 12.4.0 hb2e57f8_0 conda-forge
gcc_linux-64 12.4.0 h6b7512a_0 conda-forge
gxx 12.4.0 h236703b_0 conda-forge
gxx_impl_linux-64 12.4.0 h613a52c_0 conda-forge
gxx_linux-64 12.4.0 h8489865_0 conda-forge

As far as I can tell the only package in common is “libgcc_mutex”. I did my best to only pick out relevant packages but I may have missed some.

Blockquote
_libgcc_mutex 0.1 conda_forge conda-forge

Verified that in the PyTensor only environment the correct g++ is found.

(pytensor-env) >>> which g++
/home/grant/scratch/pytensor-env/bin/g++

g++ (conda-forge gcc 12.4.0-0) 12.4.0
In a Python prompt it did return a warning about BLAS, which was not displayed in the “PyMC” minimal environment.

>>> import pytensor
WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
>>> print(pytensor.config.cxx)
/home/grant/scratch/pytensor-env/bin/g++
2 Likes