apple / tensorflow_macos

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

Error Importing TensorFlow #101

Closed HarryOC493 closed 3 years ago

HarryOC493 commented 3 years ago

M1 MacBook Pro 16gb ram

Hi I just installed the m1 optimised version of tf using the download from this repository, I then unpacked it and ran /bin/bash Downloads/tensorflow_macos/install_venv.sh -p

after it was installed I used the command it gave me to activate the new venv then I ran python -V and python3 -V both gave me 3.8.7 then when I run python and try importing TensorFlow it gives me this error (terminal is not running in Rosetta)

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

HarryOC493 commented 3 years ago

Medium have a tutorial on how to install it, I tried that and it worked

tim-r-cruz commented 3 years ago

Can you link the medium tutorial for this?

HarryOC493 commented 3 years ago

@tim-r-cruz here: https://towardsdatascience.com/tensorflow-2-4-on-apple-silicon-m1-installation-under-conda-environment-ba6de962b3b8

tim-r-cruz commented 3 years ago

@tim-r-cruz here: https://towardsdatascience.com/tensorflow-2-4-on-apple-silicon-m1-installation-under-conda-environment-ba6de962b3b8

It worked! Thanks so much.