# Check that pymc is using the right libraries

**URL:** <https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391>\
**Category:** General\
**Created:** [May 6, 2024, 8:56am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391 "2024-05-06T08:56:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![frrfpp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/frrfpp/32/7362_2.png) [@frrfpp](https://discourse.pymc.io/u/frrfpp)\
**Post date:** [May 6, 2024, 8:56am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/1 "2024-05-06T08:56:20Z")

</div>

Hi,  
I have installed pymc on a new linux machine (a server I don’t manage) and sampling is much slower than I was expecting/get on other machines.  
Is there any way to check whether pymc is using the right optimised libraries - and in case which ones should I be looking for?  
For example I get `WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions` but this doesn’t seem to be much of an issue on other machines.  
Thanks!

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [May 6, 2024, 5:39pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/2 "2024-05-06T17:39:58Z")

</div>

It’s difficult to answer in the abstract. In general, the recommendation is to follow [the official installation instructions](https://www.pymc.io/projects/docs/en/latest/installation.html). If you have done so and are still getting the BLAS warnings (which are always a bad sign), then you can reply with the output of `conda list` and `conda config --show-sources`.

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 7, 2024, 3:26am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/3 "2024-05-07T03:26:51Z")

</div>

My understanding is that if you have an intel process, you need to make sure you have the following packages:

- `mkl`
- `mkl-service`
- `libblas=*=*mkl*`

If it’s a mac ARM64 you need `libblas=*=*accelerate*` (and none of the `mkl` related support packages). For AMD processors, I have no idea. The list of all supported conda-forge BLAS installations is [here.](https://conda-forge.org/docs/maintainer/knowledge_base/#switching-blas-implementation)

…but always follow the official instructions, because if you just use conda in the first place it handles this all for you automatically.

---

<div class="post-metadata">

**Author:** ![frrfpp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/frrfpp/32/7362_2.png) [@frrfpp](https://discourse.pymc.io/u/frrfpp)\
**Post date:** [May 7, 2024, 5:05pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/4 "2024-05-07T17:05:44Z")

</div>

Thank you both.  
I installed everything through the official instructions. I only now realised this machine is amd, rather than intel so no mkl.  
It should be using openblas (libopenblas is installed with pymc) so maybe that causes the difference in speed.

---

<div class="post-metadata">

**Author:** ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)\
**Post date:** [May 7, 2024, 11:59pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/5 "2024-05-07T23:59:13Z")

</div>

Maybe @maresb has more insight into what should be expected on AMD?

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [May 8, 2024, 6:08am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/6 "2024-05-08T06:08:31Z")

</div>

> [@frrfpp](#):
>
> For example I get `WARNING (pytensor.tensor.blas): Using NumPy C-API based implementation for BLAS functions` but this doesn’t seem to be much of an issue on other

This can make a huge difference for certain kinds of models (specially those with large matmuls). That’s why we check and emmit that warning by default

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 8, 2024, 6:10am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/7 "2024-05-08T06:10:26Z")

</div>

But it also isn’t relevant if you use a jax/numba sampler right?

---

<div class="post-metadata">

**Author:** ![ricardoV94](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/ricardov94/32/5775_2.png) [@ricardoV94](https://discourse.pymc.io/u/ricardoV94)\
**Post date:** [May 8, 2024, 6:11am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/8 "2024-05-08T06:11:03Z")

</div>

Right, sorry if I missed that was the use case

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 8, 2024, 6:15am UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/9 "2024-05-08T06:15:47Z")

</div>

It wasn’t mentioned in the OP, but if getting BLAS set up correct is totally off the table (due to permissions or w/e), maybe just using an alternative sampler would be good work-around.

---

<div class="post-metadata">

**Author:** ![frrfpp](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/frrfpp/32/7362_2.png) [@frrfpp](https://discourse.pymc.io/u/frrfpp)\
**Post date:** [May 8, 2024, 1:23pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/10 "2024-05-08T13:23:43Z")

</div>

I’m actually using the numpyro sampler for some of the models I’m testing - some don’t have jax wrappers so I need to use the pymc sampler.  
Thank you all for the help!

---

<div class="post-metadata">

**Author:** ![drbenvincent](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/drbenvincent/32/4313_2.png) [@drbenvincent](https://discourse.pymc.io/u/drbenvincent)\
**Post date:** [May 9, 2024, 12:09pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/11 "2024-05-09T12:09:08Z")

</div>

on my apple silicon machine I’m getting no `libblas=*=*accelerate*`, but I do get…

```auto
libblas 3.9.0 22_osxarm64_openblas conda-forge

```

I assume that’s kosher?

---

<div class="post-metadata">

**Author:** ![jessegrabowski](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/jessegrabowski/32/5010_2.png) [@jessegrabowski](https://discourse.pymc.io/u/jessegrabowski)\
**Post date:** [May 9, 2024, 12:17pm UTC](https://discourse.pymc.io/t/check-that-pymc-is-using-the-right-libraries/14391/12 "2024-05-09T12:17:52Z")

</div>

Yeah I believe this is the accelerate blas (it’s what I get on my mac as well)

Edit: They’re not the same but should be comparable, see [here](https://github.com/pytorch/pytorch/issues/71712)
