apple / tensorflow_macos

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

Import TensorFlow with wrong architecture error #209

Open LeoLT opened 3 years ago

LeoLT commented 3 years ago

Hello,

I'm totally new to TensorFlow and I tried to install l it on my M1 Mac. I was following the steps on this link: https://claytonpilat.medium.com/tutorial-tensorflow-on-an-m1-mac-using-jupyter-notebooks-and-miniforge-dbb0ef67bf90

But instead of creating a conda environment, I used the original python 3.8 on conda because when I installed with the environment (with the conda activate "name env"), i kept getting this issue: https://github.com/apple/tensorflow_macos/issues/48 I tried to follow the solution to reinstall the python38. But it seems like the installation didn't affect the creation of the environmental of conda. Which means when I did "conda create xxx python=3.8", it seems like that conda still tried to download a 3.8 version of python from the Internet instead of using what I installed myself with the "xcode-select --install "

So I was using the original python 3.8 on anaconda which means when I typed "which python" I got: /Users/username/opt/anaconda3/bin/python instead of /Users/username/opt/anaconda3/envs/python38/bin/python

And then I continued with the steps and all the "pip install" and "conda install" succeed without returning any error or warning.

Then I start my python and tri to import TensorFlow and here's what I got:

import tensorflow Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'tensorflow'

However I noticed that the last step was installing a tensorboard so I tried to import this package and the import didn't return the error. So I guess the installation was sort of successful?

So I didn't quite sure what I did wrong unless it was because that I didn't use the env create by "conda create". If it was the cause, what should I do to avoid the error mentioned in the issue above?

Thanks

LeoLT commented 3 years ago

Update:

Now it seems that I succeed installing the TensorFlow package for both environments (Conda and the environment created by conda create).

But when I try to import the TensorFlow I got the error from this issue: https://github.com/apple/tensorflow_macos/issues/28

I got exactly the same output in this issue for "file $(which python)" (base) tao@MBP-de-LIANGTAO arm64 % file $(which python)
/Users/tao/opt/anaconda3/bin/python: Mach-O 64-bit executable x86_64

I didn't find a solution in that issue so I'm wondering if anyone has an idea?

Thanks

hannesa2 commented 3 years ago

Now it seems that I succeed installing the TensorFlow package for both environments (Conda and the environment created by conda create).

In a Conda environment I did successfully this https://github.com/apple/tensorflow_macos/issues/153#issuecomment-803575622 and keep attention to https://github.com/apple/tensorflow_macos/issues/153#issuecomment-803141273 Maybe it helps