BLAS from the PAS

I see some dead unresolved threads from 2019 and 2020 (unlike Osment). Wondering if there is an update.

I’ve got this message

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

This appears common. Pymc3 works but apparently can be sped up.

What BLAS must I install? I am running Ubuntu 18.04, if that helps, Pymc3 was installed via conda, version 3.11.2, using the wiki on installation for linux machines. But no cigar.

2 Likes

See this link for a previous (and incomplete) discussion on BLAS
Theano Has a Blas

If you type conda search pymc3 --info, the following information appears:

pymc3 3.11.2 pyhd8ed1ab_0
-------------------------
file name   : pymc3-3.11.2-pyhd8ed1ab_0.tar.bz2
name        : pymc3
version     : 3.11.2
build       : pyhd8ed1ab_0
build number: 0
size        : 616 KB
license     : Apache-2.0
subdir      : noarch
url         : https://conda.anaconda.org/conda-forge/noarch/pymc3-3.11.2-pyhd8ed1ab_0.tar.bz2
md5         : 0c8fda4ca867ec8c8dc5ed63ee8efbeb
timestamp   : 2021-03-15 13:09:55 UTC
dependencies: 
  - arviz >=0.11.0
  - cachetools >=4.2.1
  - dill
  - fastprogress >=0.2.0
  - mkl-service
  - numpy >=1.15.0
  - pandas >=0.24.0
  - patsy >=0.5.1
  - python >=3.7
  - scipy >=1.2.0
  - semver
  - theano-pymc 1.1.2
  - typing-extensions >=3.7.4

I assume that you have the most recent version for every package. Next, check the output for:

import numpy as np
np.show_config()

For me, the output is:

blas_info:
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/home/rosgori/anaconda3/lib']
    include_dirs = ['/home/rosgori/anaconda3/include']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/home/rosgori/anaconda3/lib']
    include_dirs = ['/home/rosgori/anaconda3/include']
    language = c
lapack_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas']
    library_dirs = ['/home/rosgori/anaconda3/lib']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas', 'cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/home/rosgori/anaconda3/lib']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/home/rosgori/anaconda3/include']
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2
    not found = AVX512F,AVX512CD,AVX512_KNL,AVX512_KNM,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL

From here, you have to install the library you want. I have in my environment

$ conda list mkl
# packages in environment at /home/rosgori/anaconda3:
#
# Name                    Version                   Build  Channel
mkl                       2020.4             h726a3e6_304    conda-forge
mkl-service               2.3.0            py38h1e0a361_2    conda-forge

$ conda list blas
# packages in environment at /home/rosgori/anaconda3:
#
# Name                    Version                   Build  Channel
blas                      2.110                  openblas    conda-forge
blas-devel                3.9.0               10_openblas    conda-forge
libblas                   3.9.0               10_openblas    conda-forge
libcblas                  3.9.0               10_openblas    conda-forge
libopenblas               0.3.17          pthreads_h8fe5266_1    conda-forge
openblas                  0.3.17          pthreads_h4748800_1    conda-forge

It really helps to be in the conda-forge channel.

@rosgori, What’s the OS in which you ran these commands? Struggling here to correctly install pymc3 in Windows 10, even by just referencing to conda-forge channel. Same warning reported by @pythonometrist showing up here.

I am using Ubuntu 20.04, using conda (as you can see) and the main channel is conda-forge.

Wow you are fortunate - couldnt get Pymc3 to work on windows at all. Did you just follow the wiki?

Very helpful:
I went through your steps:

  1. conda search pymc3 --info
pymc3 3.8 py_0
--------------
file name   : pymc3-3.8-py_0.conda
name        : pymc3
version     : 3.8
build       : py_0
build number: 0
size        : 694 KB
license     : Apache-2.0
subdir      : noarch
url         : https://repo.anaconda.com/pkgs/main/noarch/pymc3-3.8-py_0.conda
md5         : 0e9fc9b6e0687e5bf40238586876ca31
timestamp   : 2020-02-20 20:01:46 UTC
dependencies: 
  - arviz
  - h5py >=2.7.0
  - numpy >=1.13.0
  - pandas >=0.18.0
  - patsy >=0.4.0
  - python >=3.5
  - scipy >=0.18.1
  - theano >=1.0.4
  - tqdm >=4.8.4

Interestingly 3.11.2 doesnt show up (even though I was able to install it. Neither does theano-pymc.

It shows lots of versions before and including pymc 3.8

Then
2. np.show_config says

blas_mkl_info:
  NOT AVAILABLE
blis_info:
  NOT AVAILABLE
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_mkl_info:
  NOT AVAILABLE
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
lapack_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    language = c
    define_macros = [('HAVE_CBLAS', None)]

So clearly I am missing some blas libraries

  1. And conda list mkl says this
# Name                    Version                   Build  Channel
mkl                       2021.2.0           h06a4308_296  
mkl-service               2.3.0            py38h27cfd23_1  
mkl_fft                   1.3.0            py38h42c9631_2  
mkl_random                1.2.1            py38ha9443f7_2 

So mkl is in play
4. And conda list blas says:

# packages in environment at /home/ubuntu/anaconda3:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl  

missing blas libraries. Next step will be to try and fgure out f I can install some blas library.

For Windows, try creating a new fresh conda environment following the instructions on Installation Guide (Windows) · pymc-devs/pymc3 Wiki · GitHub.

I’ve had the same problem with blas in Windows, and this procedure worked for me. Hopefully, it can help you as well.

The crucial catch seems to be: install dependencies with conda and conda-forge, but install pymc3 using pip afterwards.

@rladeira

That’s an inception level twist . Many thanks - will check with pip at the end.

So now numpy shows :

blas_info:
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    include_dirs = ['/root/anaconda3/envs/bayes/include']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    include_dirs = ['/root/anaconda3/envs/bayes/include']
    language = c
lapack_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas', 'cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/root/anaconda3/envs/bayes/include']
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2,AVX512F,AVX512CD,AVX512_SKX,AVX512_CLX
    not found = AVX512_KNL,AVX512_KNM,AVX512_CNL,AVX512_ICL

So looks good

# Name                    Version                   Build  Channel
mkl                       2021.3.0           h06a4308_520  
mkl-devel                 2021.3.0           h66538d2_520  
mkl-include               2021.3.0           h06a4308_520  
mkl-service               2.4.0            py38h497a2fe_0    conda-forge

Could be that I need mkl also on conda-forge

# Name                    Version                   Build  Channel
blas                      1.0                         mkl  
blas-devel                3.9.0                    10_mkl    conda-forge
libblas                   3.9.0                    10_mkl    conda-forge
libcblas                  3.9.0                    10_mkl    conda-forge
libopenblas               0.3.13               h4367d64_0  
openblas                  0.3.3             h9ac9557_1001    conda-forge

But the infor search results in this

pymc3 3.6 py37_0
----------------
file name   : pymc3-3.6-py37_0.conda
name        : pymc3
version     : 3.6
build       : py37_0
build number: 0
size        : 983 KB
license     : Apache-2.0
subdir      : linux-64
url         : https://repo.anaconda.com/pkgs/main/linux-64/pymc3-3.6-py37_0.conda
md5         : d10609e94d0532ab4f69c87ac822cb55
timestamp   : 2018-12-28 17:03:42 UTC
dependencies: 
  - h5py >=2.7.0
  - joblib <0.13.0
  - matplotlib >=1.5.0
  - numpy >=1.13.0
  - pandas >=0.18.0
  - patsy >=0.4.0
  - python >=3.7,<3.8.0a0
  - scipy >=0.12.0
  - six >=1.10.0
  - theano >=1.0.0
  - tqdm >=4.8.4


pymc3 3.7 py_0
--------------
file name   : pymc3-3.7-py_0.conda
name        : pymc3
version     : 3.7
build       : py_0
build number: 0
size        : 652 KB
license     : Apache-2.0
subdir      : noarch
url         : https://repo.anaconda.com/pkgs/main/noarch/pymc3-3.7-py_0.conda
md5         : 776f4475d2402db993650f64300a6e81
timestamp   : 2019-09-24 21:19:22 UTC
dependencies: 
  - h5py >=2.7.0
  - numpy >=1.13.0
  - pandas >=0.18.0
  - patsy >=0.4.0
  - python >=3.5
  - scipy >=0.18.1
  - theano >=1.0.4
  - tqdm >=4.8.4


pymc3 3.8 py_0
--------------
file name   : pymc3-3.8-py_0.conda
name        : pymc3
version     : 3.8
build       : py_0
build number: 0
size        : 694 KB
license     : Apache-2.0
subdir      : noarch
url         : https://repo.anaconda.com/pkgs/main/noarch/pymc3-3.8-py_0.conda
md5         : 0e9fc9b6e0687e5bf40238586876ca31
timestamp   : 2020-02-20 20:01:46 UTC
dependencies: 
  - arviz
  - h5py >=2.7.0
  - numpy >=1.13.0
  - pandas >=0.18.0
  - patsy >=0.4.0
  - python >=3.5
  - scipy >=0.18.1
  - theano >=1.0.4
  - tqdm >=4.8.4

In the notebook though

print(f"Running on PyMC3 v{pm.__version__}")
Running on PyMC3 v3.11.2

Any clues would be welcome.

May I add, on ubuntu 18.04, the default conda-forge pymc3 is 3.9. I have to specify the version 3.11.2 in order to get it

Wait a minute, did you install conda in the root directory?

blas_info:
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    include_dirs = ['/root/anaconda3/envs/bayes/include']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    include_dirs = ['/root/anaconda3/envs/bayes/include']
    language = c
lapack_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas', 'cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/root/anaconda3/envs/bayes/lib']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/root/anaconda3/envs/bayes/include']
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2,AVX512F,AVX512CD,AVX512_SKX,AVX512_CLX

Don’t do that, it is better to install in home/$USER. Try to upgrade blas. Try to use python 3.8 or 3.9. Also, to check the requirements of pymc3:

$ conda list pymc3
# packages in environment at /home/rosgori/anaconda3:
#
# Name                    Version                   Build  Channel
pymc3                     3.11.2           py38h83c9d95_3    conda-forge

Pay attention to build.

$ conda search pymc3 --info | grep -A 20 -i py38h83c9d95_3
pymc3 3.11.2 py38h83c9d95_3
---------------------------
file name   : pymc3-3.11.2-py38h83c9d95_3.tar.bz2
name        : pymc3
version     : 3.11.2
build       : py38h83c9d95_3
build number: 3
size        : 1.1 MB
license     : Apache-2.0
subdir      : linux-64
url         : https://conda.anaconda.org/conda-forge/linux-64/pymc3-3.11.2-py38h83c9d95_3.tar.bz2
md5         : 3d3d2895184b4e077ac19e2e7dd5dfc9
timestamp   : 2021-06-21 11:58:03 UTC
dependencies: 
  - arviz >=0.11.0
  - cachetools >=4.2.1
  - cxx-compiler
  - dill
  - fastprogress >=0.2.0
  - mkl-service
  - numpy >=1.15.0
  - pandas >=0.24.0
  - patsy >=0.5.1
  - python >=3.8,<3.9.0a0
  - python_abi 3.8.* *_cp38
  - scipy >=1.2.0
  - semver
  - theano-pymc 1.1.2
  - typing-extensions >=3.7.4

Of course, the version you use may vary.

Thanks for the quick response -

Yes conda is in the root, and I am trying to use the bayes env to install pymc3. In my case I am the root owner and sole user of the vultr server.

Python is already 3.8, and while conda-forge did install 3.11.2 (after updating to ubuntu 20.04), it still shows pymc3 3.8 in the conda search pymc3 --info. Let me reinstall conda and see what happens in one of my environments

Not sure whats going on.
Update - resintalled anaconda from scratch. This time blas was already loaded (so very good), but it kept wanting to isntall v 3.8 of pymc3 by default. I wonder if there is something wrong now with conda forge channel for pymc3.

Alright - Some cigar

After upgrading ubuntu to 20.04, reinstalling anaconda, and then installing each package of blas, mkl, from conda-forge, and then installing numpy, pandas and scikity learn, and then using conda forge for pymc3==3.11.2 (the other channels have older versions and so does conda-forge.And catching an error that said
WARNING (theano.configdefaults): g++ not detected !
And then installing g++,

I finally have no error message around blas or theano. WHen I feel saner, I will document the steps here, so other newbies can feel a little less overwhelmed.

For any new reader who’s having this same problem:

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

this is what fixed it for me: when you look at conda list mkl and you see a 2021.-- (vesion of mkl) try downgrading it to 2020.4 version by using the comand conda intall mkl=2020.4 I Hope this helps, it took me 2 days trying to figure out what was going on. Perhaps someone can try using a few versions of mkl and see if it is trully related to that. Happy pymc3 learning.