Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh: illegal hardware instruction" error on Mac OS, M1 chip #575

Open
MarcoEng77 opened this issue Nov 1, 2024 · 3 comments
Open

zsh: illegal hardware instruction" error on Mac OS, M1 chip #575

MarcoEng77 opened this issue Nov 1, 2024 · 3 comments
Labels
question Further information is requested

Comments

@MarcoEng77
Copy link

MarcoEng77 commented Nov 1, 2024

  • Orion version: 0.6.1
  • Python version: 3.11
  • Operating System: Mac OS (M1 chip)

Description

Trying to creare an Orion object, the Jupyter notebook hangs forever, without crashing or erroring.
Running the same commands in a script, I get the error zsh: illegal hardware instruction

What I Did

I installed orion-ml using pip as recommended in a freshly minted conda environment, with Python 3.11.
I then tried a "smoke test":

from orion.data import load_signal from orion import Orion train_data = load_signal('S-1-train') orion = Orion()

and the jupyter notebook hung forever (>10 minutes).
I tried using a python script and I got the error zsh: illegal hardware instruction

@sarahmish
Copy link
Collaborator

Hi @MarcoEng77, thank you for using Orion!

Unfortunately, I can't immediately see why the test you have done is not working. I tried it myself and everything runs as expected. I did alter the hyperparameters such that we can see the training epochs.

Python 3.11.10 (main, Oct  3 2024, 02:26:51) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from orion.data import load_signal
>>> from orion import Orion
>>> train_data = load_signal('S-1-train')
>>> orion = Orion(hyperparameters={'keras.Sequential.LSTMTimeSeriesRegressor#1': {'epochs': 5, 'verbose': True}})
>>> orion.fit(train_data)
/opt/anaconda3/envs/orion-py11/lib/python3.11/site-packages/sklearn/impute/_base.py:356: FutureWarning: The 'verbose' parameter was deprecated in version 1.1 and will be removed in 1.3. A warning will always be raised upon the removal of empty columns in the future version.
  warnings.warn(
WARNING:absl:At this time, the v2.11+ optimizer `tf.keras.optimizers.Adam` runs slowly on M1/M2 Macs, please use the legacy Keras optimizer instead, located at `tf.keras.optimizers.legacy.Adam`.
Epoch 1/5
33/33 [==============================] - 8s 194ms/step - loss: 0.4498 - mse: 0.4498 - val_loss: 0.4378 - val_mse: 0.4378
Epoch 2/5
33/33 [==============================] - 6s 182ms/step - loss: 0.4227 - mse: 0.4227 - val_loss: 0.4316 - val_mse: 0.4316
Epoch 3/5
33/33 [==============================] - 6s 189ms/step - loss: 0.4161 - mse: 0.4161 - val_loss: 0.4259 - val_mse: 0.4259
Epoch 4/5
33/33 [==============================] - 6s 192ms/step - loss: 0.4139 - mse: 0.4139 - val_loss: 0.4290 - val_mse: 0.4290
Epoch 5/5
33/33 [==============================] - 6s 193ms/step - loss: 0.4085 - mse: 0.4085 - val_loss: 0.4219 - val_mse: 0.4219

Can you share a google colab notebook showing the problem you are running into? You can also try running the following notebook.

@sarahmish sarahmish added the question Further information is requested label Nov 1, 2024
@MarcoEng77
Copy link
Author

MarcoEng77 commented Nov 4, 2024

@sarahmish thank you very much for looking into this.
I cannot use colab notebooks, but all was needed to reproduce my error was to run

from orion.data import load_signal
from orion import Orion
train_data = load_signal('S-1-train')
orion = Orion()

and I would get the error zsh: illegal hardware instruction (in the terminal, running the code as a script: the VS code jupyter notebook would simply run forever).

I have been spending quite some time tracking this down, I think it boils to the (sadly too well known!) difficulties in using Tensorflow on Mac Silicon chips (in my case M1 one). I am surprised your installation has been tested to work on MacOS M1, to the best of my knowledge the simple pip install tensorflow still does not work for Mac M1.

For now, the best (sort of) workaround I got is the following
I first install Tensorflow (2.14.1, as I see on your setup.py that Orion uses <2.15) using the procedure recommended on Mac M1, that is, using Miniforge and installing tensorflow-macos and tensorflow-metal.
In this same environment, I run pip install ml-orion, the pip installer leaves the tensorflow package untouched, and I can run your basic examples.

Will continue to try to figure it out. I take it you have tested the installation on MacOS M1, need to understand why it would not work in my case Thank you for your support and for this great library

@sarahmish
Copy link
Collaborator

Definitely, I expect so. I opened another issue #578 to mark this as a request for future releases.

For the time being, here are the versions that are installed on my machine where I have an M2 chip

tensorflow==2.14.1
tensorflow-estimator==2.14.0
tensorflow-io-gcs-filesystem==0.37.1
tensorflow-macos==2.14.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants