apple / tensorflow_macos

TensorFlow for macOS 11.0+ accelerated using Apple's ML Compute framework.
Other
3.67k stars 308 forks source link

Failed to run tensorflow with alpha3 #189

Closed tahuang1991 closed 3 years ago

tahuang1991 commented 3 years ago

Hello, I am using python3.8.8 and MacOS 11.2.1, M1 chip. I installed the alpha3 without error and then activated the virtual environment. However i still failed to import tensorflow with python3.8.8

python3 -c 'import tensorflow as tf; print(tf.version)' Traceback (most recent call last): File "/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: dlopen(/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/taohuang/tensorflow_macos_venv/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 "", line 1, in File "/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/init.py", line 41, in from tensorflow.python.tools import module_util as _module_util File "/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/init.py", line 39, in from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 83, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: dlopen(/Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/taohuang/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/taohuang/tensorflow_macos_venv/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.

hannesa2 commented 3 years ago

I don't know, if it helps you. But this is my output

image
csancineto commented 3 years ago

I had the same problem when I tried to install alpha2. To solve it, I had to:

  1. remove all Python 3.x installations (they were x86 versions);
  2. install Xcode script Command Line tools (it install Python 3.8.2 using Arm);
  3. Follow regular instructions on the original post.
tahuang1991 commented 3 years ago

Problem solved after following @csancineto 's suggestion.

to install python from command line tool using brew:

brew install python@3.8 brew link python@3.8

then i got python3.8.8 installed.

Thanks!