Hello,
I have installed tensorflow but while import I get “zsh: illegal hardware instruction” error. Can anybody please help me
Thanks
Hello,
I have installed tensorflow but while import I get “zsh: illegal hardware instruction” error. Can anybody please help me
Thanks
sounds like a problem with M1 device.
Anyidea how can I use tensorflow with M1? Thanks!
I had the same problem. Do you need any specific version? In case you don’t need any specific version you can try Apple’s fork of the official TensorFlow repo (https://github.com/apple/tensorflow_macos). If you want to install one specific version the solution is a bit trickier, but feel free to try it, it worked for me. The steps are detailed here: https://github.com/tensorflow/tensorflow/issues/46044
In short what you have to do is:
Install Rosetta2 in your Mac to enable executing Intel applications
Install Bazel to compile your Tensorflow version (you can check the instructions here https://www.tensorflow.org/install/source). This is a very important step, because you must compile Tensorflow version through Rosetta2. Otherwise, it won’t work
Build the wheel and you are done!
If you follow the comments in the Issue you will find that a user posted some wheels that he built using this method and detailed instructions, so, if you are still having trouble you should check that info.
And btw, you could always use Docker, I don’t know if you have experience with it, but if you do I’ll go that way.
Hope this was of any help!
I followed this tutorial to have successfully installed tensorflow on my m1 machine.
perhaps you can take a look: How To Install TensorFlow on M1 Mac (The Easy Way) | by Prabhat Kumar Sahu | Medium
good luck
I suggest you, to make an previous version of python in anaconda environment for example Python 3.6 is working well with Tensorflow but Python 3.9 does not!. The installation guide by this link: Managing environments — conda 4.10.3.post32+9e946176 documentation
Hope it works for you !.
Actually Apple has made Tensorflow on M1 available in the form of a Tensorflow plugin to enable training on GPU with the Metal framework. There’s a setup guide here: Tensorflow Plugin - Metal - Apple Developer
Meanwhile you can still install from the GitHub repo, which is read-only now, I recommend using the current official guide. It works for me out-of-the-box.
I did the same as mogita. As per the instructions, you will need to install miniforge3. Miniforge3 enables installing python packages natively compiled for Apple Silicon. Apple created it’s own python channel as per the instructions.
With miniforge3, installing TensorFlow was straight forward via the instructions. It seems like miniforge3 is conda with M1 support. Unfortunately, I had Python 3.10 installed on my machine. So my machine still has Python 3.10 plus Python 3.9.13 which came with miniforge3 to work with TensorFlow. So I have duplicates of the other data science libraries such as Numpy, Matplotlib etc. for the different environments. Oh well…
– Sam