简体   繁体   English

TensorFlow 2.5 Mac M1 - 安装与 NumPy 库/Conda env 的兼容性问题

[英]TensorFlow 2.5 Mac M1 - Installing problem compatibility with NumPy library / Conda env

I have a huge problem creating a conda environment with the new Tensorflow 2.5 optimized for M1 (Macbook pro-2020).我在使用针对 M1 (Macbook pro-2020) 优化的新 Tensorflow 2.5 创建 conda 环境时遇到了一个大问题。

I followed those steps:我按照以下步骤操作:

  1. install miniforge3 optimized for arm64 processor from https://github.com/conda-forge/miniforgehttps://github.com/conda-forge/miniforge安装针对 arm64 处理器优化的 miniforge3
  2. then create a conda env on the terminal ("conda create --name tf25" and "conda activate tf25")然后在终端上创建一个 conda env(“conda create --name tf25”和“conda activate tf25”)
  3. After I followed the apple guide ( https://developer.apple.com/metal/tensorflow-plugin/ )在我按照苹果指南( https://developer.apple.com/metal/tensorflow-plugin/ )之后

This is the result:这是结果:

在此处输入图片说明

In the end, when I try to import the NumPy package there is an import error.最后,当我尝试导入 NumPy 包时出现导入错误。

import numpy

Traceback (most recent call last): File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/ init .py", line 22, in from .回溯(最近通话最后一个):文件“/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/初始化py”为22行,距。 import multiarray File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in from .导入多阵列文件“/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/multiarray.py”,第12行,来自import overrides File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in from numpy.core._multiarray_umath import ( ImportError: dlopen(/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so Reason: image not found导入覆盖文件“/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/overrides.py”,第 7 行,从 numpy.core._multiarray_umath 导入(导入错误:dlopen( /Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): 库未加载:@rpath/libcblas.3.dylib引用自:/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so 原因:找不到图像

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又发生了一个异常:

Traceback (most recent call last): File "", line 1, in File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/ init .py", line 140, in from .回溯(最近通话最后一个):文件“”,1号线,在文件“/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/初始化的.py”,线路140,在从 。 import core File "/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/ init .py", line 48, in raise ImportError(msg) ImportError:进口核心文件“/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/初始化的.py”,48行,以提高导入错误(MSG)导入错误:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!重要提示:请阅读本文以获取有关如何解决此问题的建议!

Importing the numpy C-extensions failed.导入 numpy C 扩展失败。 This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.发生此错误的原因有很多,通常是您的设置问题或 NumPy 的安装方式。

We have compiled some common reasons and troubleshooting tips at:我们在以下位置汇总了一些常见原因和故障排除提示:

 https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:请注意并检查以下内容:

  • The Python version is: Python3.9 from "/Users/antoniosquicciarini/miniforge3/envs/tf25/bin/python" Python 版本是:Python3.9 来自“/Users/antoniosquicciarini/miniforge3/envs/tf25/bin/python”
  • The NumPy version is: "1.19.5" NumPy 版本是:“1.19.5”

and make sure that they are the versions you expect.并确保它们是您期望的版本。 Please carefully study the documentation linked above for further help.请仔细研究上面链接的文档以获得进一步的帮助。

Original error was: dlopen(/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Library not loaded: @rpath/libcblas.3.dylib Referenced from: /Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so原始错误是:dlopen(/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2):库未加载:@rpath /libcblas.3.dylib 引用自:/Users/antoniosquicciarini/miniforge3/envs/tf25/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so

Reason: image not found原因:找不到图片

I already tried to:我已经尝试过:

  • Install numpy with pip使用 pip 安装 numpy
  • Install a lower version of python (3.8)安装低版本的python(3.8)

I think there is a compatibility problem with the new TensorFlow an NumPy library, because until today I used the TensorFlow 2.4 in another conda env我认为新的 TensorFlow 和 NumPy 库存在兼容性问题,因为直到今天我在另一个 conda 环境中使用了 TensorFlow 2.4

The answer was posted here答案已发布在这里

Original error was: dlopen(/Users/ulto4/miniforge3/envs/python386/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 2): 原始错误是:dlopen(/Users/ulto4/miniforge3/envs/python386/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 2):

You need to install openblas :您需要安装openblas

conda install -c conda-forge openblas

This fixed the error and numpy works.这修复了错误并且 numpy 工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM