Conda:如何防止 mkl 到 openblas 切换

发布于 2025-01-11 15:53:11 字数 1974 浏览 0 评论 0原文

Conda 想要将我的 blas、lapack 等软件包从 mkl 降级为 openblas 版本。我知道 conda 与 mkl 和 openblas 的混合似乎并不是一个不常见的问题。然而,我还没有找到适合我的解决方案。我安装了这些软件包

blas                      2.113                       mkl    conda-forge
blas-devel                3.9.0            13_linux64_mkl    conda-forge
libblas                   3.9.0            13_linux64_mkl    conda-forge
libcblas                  3.9.0            13_linux64_mkl    conda-forge
liblapack                 3.9.0            13_linux64_mkl    conda-forge
liblapacke                3.9.0            13_linux64_mkl    conda-forge
mkl                       2022.0.1           h06a4308_117  
mkl-devel                 2022.0.1           h66538d2_117  
mkl-include               2022.0.1           h06a4308_117  
mkl-service               2.4.0            py39h404a4ab_0    conda-forge
mkl_fft                   1.3.1            py39h6964271_2    conda-forge
mkl_random                1.2.2            py39h8b66066_1    conda-forge

,并且有一个 .condarc (在 Linux 上),其中包含

channels:
  - conda-forge
  - defaults
dependencies:
  - python>=3.6
  - numpy>=1.13
  - scipy>=0.18
  - cython>=0.29
  - mkl
  - mkl-devel
  - libblas=*=*mkl
  - bottleneck
  - pip
  - setuptools>=30.3.0
  - h5py
  - pyyaml
  - pytest

ssl_verify: true
auto_activate_base: false

此外,在 conda-meta 目录中我有一个 pinned 文件,包含行 libblas=*=*mkl。然而,在 conda update --all 上建议:

The following packages will be DOWNGRADED:
  ... other pkgs ...
  libblas                              3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas
  libcblas                             3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas
  liblapack                            3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas

为什么,尽管有 .condarcpinned 文件,我还是得到了这个开关从 mkl 到 openblas,我还能做些什么来防止它?

Conda wants to downgrade my blas, lapack etc. packages from an mkl to an openblas version. I understand that conda juggling with mkl versus openblas seems not an uncommon issue. Yet, I have not found a solution to do the job for me. I have these packages installed

blas                      2.113                       mkl    conda-forge
blas-devel                3.9.0            13_linux64_mkl    conda-forge
libblas                   3.9.0            13_linux64_mkl    conda-forge
libcblas                  3.9.0            13_linux64_mkl    conda-forge
liblapack                 3.9.0            13_linux64_mkl    conda-forge
liblapacke                3.9.0            13_linux64_mkl    conda-forge
mkl                       2022.0.1           h06a4308_117  
mkl-devel                 2022.0.1           h66538d2_117  
mkl-include               2022.0.1           h06a4308_117  
mkl-service               2.4.0            py39h404a4ab_0    conda-forge
mkl_fft                   1.3.1            py39h6964271_2    conda-forge
mkl_random                1.2.2            py39h8b66066_1    conda-forge

and I have a .condarc (on linux) containing

channels:
  - conda-forge
  - defaults
dependencies:
  - python>=3.6
  - numpy>=1.13
  - scipy>=0.18
  - cython>=0.29
  - mkl
  - mkl-devel
  - libblas=*=*mkl
  - bottleneck
  - pip
  - setuptools>=30.3.0
  - h5py
  - pyyaml
  - pytest

ssl_verify: true
auto_activate_base: false

Moreover in the conda-meta directories I have a pinned file, containing the line libblas=*=*mkl. Yet, upon conda update --all this is suggested:

The following packages will be DOWNGRADED:
  ... other pkgs ...
  libblas                              3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas
  libcblas                             3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas
  liblapack                            3.9.0-13_linux64_mkl --> 3.9.0-13_linux64_openblas

Why, despite of the the .condarc and pinned files, am I getting this switch from mkl to openblas, and what else can I do to prevent it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人生戏 2025-01-18 15:53:11

请参阅 https://conda-forge 末尾的注释部分.org/docs/maintainer/knowledge_base.html#switching-blas-implementation

如果您想提交特定的 blas 实现,您可以通过在您的环境中固定 blas 实现来防止 conda 切换回来。要提交 mkl,请将 blas=*=mkl 添加到 /envs//conda-meta/pinned,如所述在 conda 文档中。

See the note section at the end of https://conda-forge.org/docs/maintainer/knowledge_base.html#switching-blas-implementation

If you want to commit to a specific blas implementation, you can prevent conda from switching back by pinning the blas implementation in your environment. To commit to mkl, add blas=*=mkl to <conda-root>/envs/<env-name>/conda-meta/pinned, as described in the conda-docs.

孤星 2025-01-18 15:53:11

我正在为我自己的操作发布一个奇怪的解决方法。这终于对我有用了。

首先,我无法说服 conda 尊重 .condarc 中的频道顺序以及 中的内容>在通过任何其他建议运行更新之前固定文件,包括在stackoverflow之外找到的文件。

第二,我存储了一个conda列表 | grep mkl,一个 conda 列表 | grep intel 和 conda 列表 | grep open 供以后参考。然后我“屈服”并让“升级”发生,运行 conda update --all。不用说,在那之后,我的环境确实显示了所有 mkl 类型库被 openblas 内容不必要的替换。

第三,在 openblas 感染的环境中,我“重新安装”了 mkl

    conda install blas=*=*mkl
    conda install libblas=*=*mkl
    conda update numpy
    conda update scipy
    conda install intel-openmp   # the "update" had also removed this ...

同时确保没有 openblas -stuff 通过在任何相关包上执行 conda remove 来保留。 (我并不是说上述所有命令实际上都是达到 mkl 环境的原始状态所必需的。但这就是我所做的。)

第四,比较根据前面第二步骤的参考说明,我检查了此时我的环境声称已返回“all-mkl”。此外,使用这个非常有用的网站 http://markus-beuckelmann.de/blog /boosting-numpy-blas.html 我还检查了,对于预期的典型 mkl 计时来说,这确实是正确的。

另一方面,有一个非常奇怪和令人困惑的问题,它可能与OP无关,但我在这种情况下偶然发现:在WWW上,人们发现了很多许多引用指出,对于 numpy 或 scipy 实际“使用”mkl 来说,必须有这种

    In []: numpy.show_config()
    blas_mkl_info:
        libraries = ['mkl_rt', 'pthread']
        library_dirs = ['/home/abcd/efgh..../lib']

输出numpy/scipy.show_confi()。总的来说,这似乎不正确。事实上,当人们得到

    In []: numpy.show_config()
    blas_info:
        libraries = ['cblas', 'blas', 'cblas', 'blas']
        library_dirs = ['/home/abcd/efgh..../lib']

这一点时,只要在 /home/abcd/efgh..../lib 中人们发现一切都像

    liblapacke.so -> libmkl_rt.so.2*
    libblas.so -> libmkl_rt.so.2*
    ...a.s.o.

我所做的那样链接,就不会引起恐慌。

conda 太痛苦了。叹息)

I'm posting a quirky workaround for my own OP. This finally worked for me.

First, I could not convince conda to respect the channel ordering in .condarc nor the content in the pinned files before running the update by any other suggestion, including those found outside of stackoverflow .

Second, I stored a conda list | grep mkl, a conda list | grep intel, and a conda list | grep open away for later reference. Then I "gave in" and let the "upgrade" happen, running conda update --all. No need to mention that after that, my environment indeed showed the unwanted replacement of all mkl-type libraries with openblas stuff.

Third, and within the openblas-infested environment I "re-installed" mkl

    conda install blas=*=*mkl
    conda install libblas=*=*mkl
    conda update numpy
    conda update scipy
    conda install intel-openmp   # the "update" had also removed this ...

Also make sure that no openblas-stuff remains by doing a conda remove on whatever related package. (I'm not claiming that really all of the above commands are necessary to reach the original state of the environment regarding mkl. But that's what I did.)

Fourth, comparing with the reference notes from the preceding second step I checked that at this point my environment claimed to be back to "all-mkl". Moreover, using this extremely helpful site http://markus-beuckelmann.de/blog/boosting-numpy-blas.html I also checked, that this was indeed true regarding typical mkl timings to be expected.

On the side, there is a really weird and confusing issue, which may not be related to the OP but which I stumbled across in this context: On the WWW one finds many many many quotes stating, that for numpy or scipy actually "using" mkl, one has to have this kind of output

    In []: numpy.show_config()
    blas_mkl_info:
        libraries = ['mkl_rt', 'pthread']
        library_dirs = ['/home/abcd/efgh..../lib']

from numpy/scipy.show_confi(). This seems not true in general. In fact when one gets

    In []: numpy.show_config()
    blas_info:
        libraries = ['cblas', 'blas', 'cblas', 'blas']
        library_dirs = ['/home/abcd/efgh..../lib']

this is no cause for panic as long as in /home/abcd/efgh..../lib one finds everything linked as

    liblapacke.so -> libmkl_rt.so.2*
    libblas.so -> libmkl_rt.so.2*
    ...a.s.o.

which I do.

(conda is just soo painful. sigh)

§对你不离不弃 2025-01-18 15:53:11

每当 Intel MKL 包更新但 numpy 包没有更新时,包管理就会变得一团糟。我最终可能会安装 Intel MKL,但 numpy 使用的是 openblas。为了在我的设置中实现此功能,我经常在创建新环境时执行此操作:

conda create  -y --name test python=3 numpy mkl cmake blas=*=*mkl

以便与 numpy 同时安装 MKL,并且 numpy 将使用 MKL。这通常会导致旧版本的 MKL,因为 numpy 与旧版本的 MKL 链接。

如果没有 blas=*=*mkl,我通常会得到一个基于 openblas 的 numpy,并且安装了最新版本的 Intel MKL,但没有任何东西使用。

conda create -n test33 numpy mkl blas=*=*mkl
.
.
.
The following NEW packages will be INSTALLED:

  blas               pkgs/main/osx-64::blas-1.0-mkl
.
  numpy              pkgs/main/osx-64::numpy-1.21.5-py39h2e5f0a9_1
.
  mkl                pkgs/main/osx-64::mkl-2021.4.0-hecd8cb5_637
.

# results in:
blas_opt_info:
    libraries = ['mkl_rt', 'pthread']

conda create -n test33 numpy mkl
.
.
.
The following NEW packages will be INSTALLED:

  blas               pkgs/main/osx-64::blas-1.0-openblas
.
  numpy              pkgs/main/osx-64::numpy-1.21.5-py39h9c3cb84_1
.
  mkl                pkgs/main/osx-64::mkl-2022.0.0-hecd8cb5_105
.

# results in:
blas_opt_info:
    libraries = ['openblas', 'openblas']

不幸的是,numpy 似乎没有在其版本 ID 中显示它所链接的 blas 库。通常,您的环境中最终会同时出现 openblas 和 mkl。

The package management can be a mess whenever the Intel MKL package has been updated, but the numpy package has not. I may end up with Intel MKL being installed, but numpy is using the openblas. To get this working in my setup, I often do this when creating a new environment:

conda create  -y --name test python=3 numpy mkl cmake blas=*=*mkl

so that the MKL is installed at the same time as numpy, and numpy will use the MKL. This often results in an older version of MKL, since numpy was linked against an older version of the MKL.

Without the blas=*=*mkl, I will often end up with an openblas based numpy installed with the newest version of the Intel MKL not being used by anything.

conda create -n test33 numpy mkl blas=*=*mkl
.
.
.
The following NEW packages will be INSTALLED:

  blas               pkgs/main/osx-64::blas-1.0-mkl
.
  numpy              pkgs/main/osx-64::numpy-1.21.5-py39h2e5f0a9_1
.
  mkl                pkgs/main/osx-64::mkl-2021.4.0-hecd8cb5_637
.

# results in:
blas_opt_info:
    libraries = ['mkl_rt', 'pthread']

conda create -n test33 numpy mkl
.
.
.
The following NEW packages will be INSTALLED:

  blas               pkgs/main/osx-64::blas-1.0-openblas
.
  numpy              pkgs/main/osx-64::numpy-1.21.5-py39h9c3cb84_1
.
  mkl                pkgs/main/osx-64::mkl-2022.0.0-hecd8cb5_105
.

# results in:
blas_opt_info:
    libraries = ['openblas', 'openblas']

Unfortunately, numpy does not appear to show the blas library it is linked against in its version id. Oftentimes, you will end up with both openblas and mkl in your environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文