apple / tensorflow_macos

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

Failed to load the native TensorFlow runtime on Mac M1 #212

Open Kaggia opened 3 years ago

Kaggia commented 3 years ago

Hello, I've just tried to run a simple import of Tensorflow, while I'm doing that the console just says: "Failed to load the native TensorFlow runtime".

This is what I did:

  1. /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/apple/tensorflow_macos/master/scripts/download_and_install.sh)"
  2. Choose default option as virtual enviroment
  3. chmod +x activate
  4. source activate
  5. python command
  6. import tensorflow as tf

This is the complete stacktrace:

Traceback (most recent call last): File "/Users/stefanozimmitti/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/stefanozimmitti/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/stefanozimmitti/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/stefanozimmitti/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/stefanozimmitti/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/stefanozimmitti/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/stefanozimmitti/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/stefanozimmitti/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/stefanozimmitti/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): no suitable image found. Did find: /Users/stefanozimmitti/tensorflow_macos_venv/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: mach-o, but wrong architecture /Users/stefanozimmitti/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.

How can I solve this? And run successfully Tensorflow on my new Mac M1?

12Arrows commented 3 years ago

same here, need some insight~

pdxrod commented 3 years ago

I should have commented here before describing my experiences on Stackoverflow, but here it is: https://stackoverflow.com/questions/56604348/how-to-install-tensorflow-2-0-on-mac-or-linux/67057288#67057288

In a nutshell, the script in tensorflow_macos/scripts ./download_and_install.sh downloads something, but then tells you to run activate, located in a directory underneath /private which does not exist. I tried four different methods, three of them recommended by Apple, and another recommended by the above page from Stackoverflow. All the Apple methods failed with the same issue - referring to a non-existent activate program, and the other method, using conda, failed because it only knows of tensorflow packages up to Python 3.5, and Apple Tensorflow requires Python 3.8.

What am I missing? I'd be grateful for any response, even if it's to tell me I've missed something obvious.

Shunya11 commented 3 years ago

same here

shen-jiabin commented 3 years ago

same here

WenAnChen commented 3 years ago

same here. need help

rvillacis commented 3 years ago

Same here

keloee commented 3 years ago

same here