【问题标题】:Installing Tensorflow in M1 Mac在 M1 Mac 中安装 TensorFlow
【发布时间】:2021-07-25 00:00:21
【问题描述】:

我按照本教程 https://www.youtube.com/watch?v=ykCY_tJbhNw 在 mac(M1 处理器)中安装 tensorflow。但是,当我导入 tensrflow 时,出现以下错误。有什么想法吗?

步骤包括,

  • 正在安装 brew(已安装)
  • 安装 conda(已安装)
  • 安装 miniforge
  • 从 github 页面下载 tensorflow-macos
  • conda activate mlEnv
  • /Users/imantha/Software/tensorflow_macos/install_venv.sh -p
  • 提示输入路径时:/Users/imantha/Software/anaconda3/envs/mlEnv/
  • 选择yes安装tensorflow
  • tensorflow 安装成功,输入 conda list 时,会列出包。

但是,当我在 shell 中启动 python 会话并输入 import tensorflow as tf 时,我收到以下错误

Traceback (most recent call last):
File "/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: dlopen(/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found.  Did find:
/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture
/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: 
dlopen(/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image 
found.  Did find:
/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong 
 architecture
/Users/imantha/Software/anaconda3/envs/mlEnv/lib/python3.8/site- 
packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong 
architecture


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

【问题讨论】:

    标签: python tensorflow anaconda apple-m1


    【解决方案1】:

    按照here 中提到的说明从源代码构建 TensorFlow。 看到这个comment。

    或,

    尝试提到的解决方法here。

    【讨论】:

      猜你喜欢
      • 2021-05-17
      • 1970-01-01
      • 2022-06-11
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      • 1970-01-01
      • 2022-01-10
      • 2021-06-21
      相关资源
      最近更新 更多