@ctrahey yours is the only solution that works for me as of 26 SEPT 2021. Default instructions from Apple install but importing tensorflow crashes python. I haven't installed jupyter or tried to load or execute my neural networks, but at least your scripts got me an environment where tensorflow doesn't immediately crash. Thanks for sharing.
Post
Replies
Boosts
Views
Activity
Sorry for the hideous formatting here, I must svk at this inter web thing...
Hello there @Frameworks Engineer, I have a similar issue 'TensorFlow and Numpy issue M1' though a different manifestation. First, here is a subset of my package environment with possible antagonists...
keras-nightly 2.5.0.dev2021032900 pypi_0 pypi
keras-preprocessing 1.1.2 pyhd8ed1ab_0 conda-forge
libgfortran 5.0.0.dev0 11_0_1_hf114ba7_23 conda-forge
libgfortran5 11.0.1.dev0 hf114ba7_23 conda-forge
matplotlib 3.4.3 pypi_0 pypi
matplotlib-inline 0.1.2 pypi_0 pypi
numpy 1.19.5 py39h1f3b974_2 conda-forge
pandas 1.3.1 pypi_0 pypi
python 3.9.6 h54d631c_1_cpython conda-forge
tensorflow-deps 2.5.0 1 apple
tensorflow-estimator 2.5.0 pypi_0 pypi
tensorflow-macos 2.5.0 pypi_0 pypi
tensorflow-metal 0.1.2 pypi_0 pypi
tfa-nightly 0.15.0.dev20210922190150 pypi_0 pypi
Late 2020 M1 with newly installed Version 12.0 Beta (21A5522h)
I can launch my Python/TF/Keras code in Jupyter, define a functional model, define a custom loss function, compile the model, and load training data, but when attempting to run model.fit() I get:
----> 2 history = model.fit(x_train,
3 y_train,
4 batch_size = TRAINING_BATCH_SIZE,
5 epochs=10,
~/miniforge3/envs/tf_macos/lib/python3.9/site-packages/tensorflow/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1131 training_utils.RespectCompiledTrainableState(self):
1132 # Creates a tf.data.Dataset and handles batch and epoch iteration.
-> 1133 data_handler = data_adapter.get_data_handler(
1134 x=x,
1135 y=y,
.
.
.
~/miniforge3/envs/tf_macos/lib/python3.9/site-packages/pandas/_libs/init.py in
11
12
---> 13 from pandas._libs.interval import Interval
14 from pandas._libs.tslibs import (
15 NaT,
~/miniforge3/envs/tf_macos/lib/python3.9/site-packages/pandas/_libs/interval.pyx in init pandas._libs.interval()
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
Welcome your thoughts and suggestions.
I am successfully training a YOLO v2 CNN on M1 using the approach and script provided by @ctrahey above. That resolved the import tensorflow crashing python, but my neural net uses pandas under the covers during training and that threw a runtime error. Resolved by uninstalling pandas, which had initially been installed using pip, and reinstalling it using Conda. My model is training as I write this. Hope it helps.
The approach and scripts mentioned above from @ctrahey worked to resolve the inability to import tensorflow into python. However, I still encountered a runtime error during model.fit() due to incompatibility in pandas. I noticed that my python and numpy were installed by conda-forge, while pandas was installed by pip. I uninstalled pandas using pip, reinstalled it using conda-forge, and the runtime error was resolved. Back to working on my loss function and training my model (where I was 2 weeks ago before deciding to try to get all this running natively instead of under the emulator).