Tensorflow metal keeps killing python

Hi, I've run into some issue with TensorFlow-metal on my Mac M1. After installing TensorFlow-metal following the official steps in my Conda environment (Miniforge), when I try to import TensorFlow, independently from which python version I use, the "import TensorFlow" command keeps killing the process (import tensorflow killed python)

any idea why this is happening? I tried different version of tensorflow-deps (both 2.5.0 and 2.6.0) and the outcome is exactly the same. Thank you!

I forgot to mention that I tried a fresh installation of everything I could, including the OS too.

Same. Multiple attempts with fresh installs of Monterey, Xcode, Miniforge etc. Used the tensorflow-deps==2.5.0 suggestion found on another thread here. Everything acted like it installed happily. Can launch python. Can't import tensorflow.

(tf_macos) ...MacBook-Pro ~ % uname -m arm64

(tf_macos) ...MacBook-Pro ~ % python                                 Python 3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:30:24)  [Clang 11.1.0 ] on darwin

import tensorflow as tf

zsh: killed     python

I found exactly same issue, too (Big Sur 11.6, M1 Air). Only tensorflow related package killed python. One strange thing was when I import tensorflow via Rosetta terminal, it worked well even though I installed via miniforge ARM tensorflow.

Update: I had success using the approach and scripts posted to GitHub by ctrahey and linked in this related thread. Haven't yet installed all the packages I want or tried to run my neural nets, but at least I can launch python, import tensorflow, and get back "Running TensorFlow 2.5.0 with 1 GPUs recognized".

 @ConatusEng I came across this solution a few days ago, but I was so frustrated with python crushing after importing TensorFlow that I didn't actually try it. Most of the packages are pinned, so it's likely some weird package updates that is making python crushing. I'll definitely give it a try! Thank you!

I have successfully resolved this issue. First, as mentioned in my comment above, I abandoned the instructions provided by Apple and went with the approach and scripts linked in the comment above, posted by @ctrahey in another thread. That allowed me to at least import tensorflow, but then I had a runtime error with pandas. Based on the stack trace I examined my python, numpy, and pandas packages. Python and numpy were installed by Conda-forge. Pandas was installed by pip. You see where I'm going here...

% conda list | grep numpy numpy                     1.19.5           py39h1f3b974_2    conda-forge

% conda list | grep pandas pandas                    1.3.1                    pypi_0    pypi

I uninstalled just the pandas package, reinstalled it using Conda instead of pip and now % conda list | grep pandas pandas                    1.3.3            py39h7f752ed_0    conda-forge

I can import numpy, tensorflow, and pandas without crashing Python, but better yet, I can compile and call model.fit() on my functional model. Back in the business of training my neural net! Thanks @ctrahey for providing the way forward

Which OS are you using ?

Tensorflow metal keeps killing python
 
 
Q